Commit 0d7e58ce authored by Ozzieisaacs's avatar Ozzieisaacs

Fix for #968 (database conversion fails for default strings under python2.7)

parent 3e008ef2
......@@ -271,8 +271,15 @@ def _migrate_table(session, orm_class):
session.query(column).first()
except exc.OperationalError as err:
log.debug("%s: %s", column_name, err)
if column.default is not None:
if sys.version_info < (3, 0):
if isinstance(column.default.arg,unicode):
column.default.arg = column.default.arg.encode('utf-8')
column_default = "" if column.default is None else ("DEFAULT %r" % column.default.arg)
alter_table = "ALTER TABLE %s ADD COLUMN `%s` %s %s" % (orm_class.__tablename__, column_name, column.type, column_default)
alter_table = "ALTER TABLE %s ADD COLUMN `%s` %s %s" % (orm_class.__tablename__,
column_name,
column.type,
column_default)
log.debug(alter_table)
session.execute(alter_table)
changed = True
......
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