Commit a7a1affb by Ned Batchelder

Merge pull request #11676 from edx/jibsheet/facebook_url_noop_migration

Noop the 0008 and conditional the 0009 migration
parents daadc1e4 7a129b0e
...@@ -11,8 +11,6 @@ class Migration(migrations.Migration): ...@@ -11,8 +11,6 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
migrations.RemoveField( # Removed because we accidentally removed this column without first
model_name='courseoverview', # removing the code that refers to this. This can cause errors in production.
name='facebook_url',
),
] ]
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models, OperationalError, connection
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
class Migration(migrations.Migration): class Migration(migrations.Migration):
...@@ -10,10 +11,17 @@ class Migration(migrations.Migration): ...@@ -10,10 +11,17 @@ class Migration(migrations.Migration):
('course_overviews', '0008_remove_courseoverview_facebook_url'), ('course_overviews', '0008_remove_courseoverview_facebook_url'),
] ]
operations = [ # An original version of 0008 removed the facebook_url field
migrations.AddField( # We need to handle the case where our noop 0008 ran AND the case
# where the original 0008 ran. We do that by using Django's introspection
# API to query INFORMATION_SCHEMA. _meta is unavailable as the
# column has already been removed from the model.
fields = connection.introspection.get_table_description(connection.cursor(),'course_overviews_courseoverview')
operations = []
if not any(f.name == 'facebook_url' for f in fields):
operations += migrations.AddField(
model_name='courseoverview', model_name='courseoverview',
name='facebook_url', name='facebook_url',
field=models.TextField(null=True), field=models.TextField(null=True),
), ),
]
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