From 4f3234433b97e7f243d54e9e95399f5cabecd315 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Thu, 14 Jan 2016 15:41:15 -0500 Subject: [PATCH] Change broken course_modes migration to not touch the database. Changing a field name in the way that we did (updating the Python variable name and switching it to point to the old DB column) confuses Django's migration autodetector. No DB changes are actually necessary, but it thinks that a field has been removed and a new one added. This means that Django will ask users to generate the migration it thinks is necessary, which ended up with us dropping data. The fix is to run the same migration on Django's internal model of the DB state, but not actually touch the DB. --- .../migrations/0005_auto_20151217_0958.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/common/djangoapps/course_modes/migrations/0005_auto_20151217_0958.py b/common/djangoapps/course_modes/migrations/0005_auto_20151217_0958.py index 0cc768b1c0df..1e6e3f7e82ee 100644 --- a/common/djangoapps/course_modes/migrations/0005_auto_20151217_0958.py +++ b/common/djangoapps/course_modes/migrations/0005_auto_20151217_0958.py @@ -11,13 +11,18 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RemoveField( - model_name='coursemode', - name='expiration_datetime', - ), - migrations.AddField( - model_name='coursemode', - name='_expiration_datetime', - field=models.DateTimeField(db_column=b'expiration_datetime', default=None, blank=True, help_text='OPTIONAL: After this date/time, users will no longer be able to enroll in this mode. Leave this blank if users can enroll in this mode until enrollment closes for the course.', null=True, verbose_name='Upgrade Deadline'), - ), + migrations.SeparateDatabaseAndState( + database_operations=[], + state_operations=[ + migrations.RemoveField( + model_name='coursemode', + name='expiration_datetime', + ), + migrations.AddField( + model_name='coursemode', + name='_expiration_datetime', + field=models.DateTimeField(db_column=b'expiration_datetime', default=None, blank=True, help_text='OPTIONAL: After this date/time, users will no longer be able to enroll in this mode. Leave this blank if users can enroll in this mode until enrollment closes for the course.', null=True, verbose_name='Upgrade Deadline'), + ), + ] + ) ]