Commit de6ca4a7 by jsa

avoid errors when forward-migrating course_groups after south conversion

JIRA: TNL-937
parent eced849d
...@@ -2,13 +2,30 @@ ...@@ -2,13 +2,30 @@
import datetime import datetime
from south.db import db from south.db import db
from south.v2 import SchemaMigration from south.v2 import SchemaMigration
from django.db import models from django.db import models, connection
class Migration(SchemaMigration): class Migration(SchemaMigration):
def forwards(self, orm): def forwards(self, orm):
# Adding model 'CourseUserGroup' # Adding model 'CourseUserGroup'
def table_exists(name):
return name in connection.introspection.table_names()
def index_exists(table_name, column_name):
return column_name in connection.introspection.get_indexes(connection.cursor(), table_name)
# Since this djangoapp has been converted to south migrations after-the-fact,
# these tables/indexes should already exist when migrating an existing installation.
if not (
table_exists('course_groups_courseusergroup') and
index_exists('course_groups_courseusergroup', 'name') and
index_exists('course_groups_courseusergroup', 'course_id') and
table_exists('course_groups_courseusergroup_users') and
index_exists('course_groups_courseusergroup_users', 'courseusergroup_id') and
index_exists('course_groups_courseusergroup_users', 'user_id')
):
db.create_table('course_groups_courseusergroup', ( db.create_table('course_groups_courseusergroup', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)), ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
......
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