Last active
November 13, 2015 09:40
-
-
Save czpython/38c9115f27fe73a24d81 to your computer and use it in GitHub Desktop.
Migrates old cms plugin table to new table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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