Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Migrates old cms plugin table to new table
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import connection, models
class Migration(DataMigration):
tables = {
'old_cmsplugin_table_name': 'new_table_name',
}
def forwards(self, orm):
table_names = connection.introspection.table_names()
for old_table, new_table in self.tables.iteritems():
if old_table in table_names:
db.rename_table(old_table, new_table)
def backwards(self, orm):
table_names = connection.introspection.table_names()
for old_table, new_table in self.tables.iteritems():
if new_table in table_names:
db.rename_table(new_table, old_table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.