Django and south newbie here
I need to change the encoding of a table I created, does anyone know a way to do so using a migration?
I think the solution will be database-specific. For example, for a MySQL database:
from south.db import db
from south.v2 import SchemaMigration
class Migration(SchemaMigration):
def forwards(self, orm):
db.execute('alter table appname_modelname charset=utf8')
db.execute('alter table appname_modelname alter column fieldname charset=utf8')
# et cetera for any other char or text columns
def backwards(self, orm):
db.execute('alter table appname_modelname charset=latin1')
db.execute('alter table appname_modelname alter column fieldname charset=latin1')
# et cetera for any other char or text columns
complete_apps = ['appname']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With