Commit ceb0814f by Calen Pennington

Force the CourseKey alter tables to be noops from the SQL perspective

parent 0faa6837
...@@ -5,6 +5,16 @@ from django.db import migrations, models ...@@ -5,6 +5,16 @@ from django.db import migrations, models
import openedx.core.djangoapps.xmodule_django.models import openedx.core.djangoapps.xmodule_django.models
# This should only be used for migrations that have be verified to have a net-neutral sql
# change generated by Django
class NoSqlAlterField(migrations.AlterField):
def database_forwards(self, app_label, schema_editor, from_state, to_state):
return
def database_backwards(self, app_label, schema_editor, from_state, to_state):
return
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
...@@ -32,7 +42,7 @@ class Migration(migrations.Migration): ...@@ -32,7 +42,7 @@ class Migration(migrations.Migration):
# name to above). # name to above).
# We deliberately leave db_constraint set to False because the column # We deliberately leave db_constraint set to False because the column
# isn't currently constrained # isn't currently constrained
migrations.AlterField( NoSqlAlterField(
model_name='coursemode', model_name='coursemode',
name='course', name='course',
field=models.ForeignKey(related_name='modes', db_constraint=False, default=None, to='course_overviews.CourseOverview'), field=models.ForeignKey(related_name='modes', db_constraint=False, default=None, to='course_overviews.CourseOverview'),
......
...@@ -41,7 +41,12 @@ class CourseMode(models.Model): ...@@ -41,7 +41,12 @@ class CourseMode(models.Model):
class Meta(object): class Meta(object):
app_label = "course_modes" app_label = "course_modes"
course = models.ForeignKey(CourseOverview, db_constraint=False, db_index=True, related_name='modes') course = models.ForeignKey(
CourseOverview,
db_constraint=False,
db_index=True,
related_name='modes',
)
# Django sets the `course_id` property in __init__ with the value from the database # Django sets the `course_id` property in __init__ with the value from the database
# This pair of properties converts that into a proper CourseKey # This pair of properties converts that into a proper CourseKey
......
...@@ -6,6 +6,16 @@ import django.db.models.deletion ...@@ -6,6 +6,16 @@ import django.db.models.deletion
import openedx.core.djangoapps.xmodule_django.models import openedx.core.djangoapps.xmodule_django.models
# This should only be used for migrations that have be verified to have a net-neutral sql
# change generated by Django
class NoSqlAlterField(migrations.AlterField):
def database_forwards(self, app_label, schema_editor, from_state, to_state):
return
def database_backwards(self, app_label, schema_editor, from_state, to_state):
return
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
...@@ -41,13 +51,13 @@ class Migration(migrations.Migration): ...@@ -41,13 +51,13 @@ class Migration(migrations.Migration):
# Alter the fields to make them ForeignKeys (leaving off the db_constraint so # Alter the fields to make them ForeignKeys (leaving off the db_constraint so
# that we don't create it at migration time). The db_column is left off because # that we don't create it at migration time). The db_column is left off because
# it defaults to ${field_name}_id, which we pinned it to up above. # it defaults to ${field_name}_id, which we pinned it to up above.
migrations.AlterField( NoSqlAlterField(
model_name='courseenrollment', model_name='courseenrollment',
name='course', name='course',
field=models.ForeignKey(db_constraint=False, to='course_overviews.CourseOverview'), field=models.ForeignKey(db_constraint=False, to='course_overviews.CourseOverview'),
preserve_default=True, preserve_default=True,
), ),
migrations.AlterField( NoSqlAlterField(
model_name='historicalcourseenrollment', model_name='historicalcourseenrollment',
name='course', name='course',
field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.DO_NOTHING, db_constraint=False, blank=True, to='course_overviews.CourseOverview', null=True), field=models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.DO_NOTHING, db_constraint=False, blank=True, to='course_overviews.CourseOverview', null=True),
......
...@@ -996,7 +996,10 @@ class CourseEnrollment(models.Model): ...@@ -996,7 +996,10 @@ class CourseEnrollment(models.Model):
user = models.ForeignKey(User) user = models.ForeignKey(User)
course = models.ForeignKey(CourseOverview, db_constraint=False) course = models.ForeignKey(
CourseOverview,
db_constraint=False,
)
@property @property
def course_id(self): def course_id(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment