Skip to content

Instantly share code, notes, and snippets.

@czpython
Last active November 13, 2015 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czpython/38c9115f27fe73a24d81 to your computer and use it in GitHub Desktop.
Save czpython/38c9115f27fe73a24d81 to your computer and use it in GitHub Desktop.
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