Issue one SQL statement per execute() call
Some sqlalchemy drivers only support a single SQL statement per execute() call. It isn't 100% clear from the sqlalchemy docs, but the sqlalchemy author confirmed that this is the intention. Change-Id: I2f696a5894ce7722114a2da054b42d9ffac56b83
This commit is contained in:
parent
c66a0f33a7
commit
676f9cba78
@ -18,14 +18,15 @@ def upgrade(migrate_engine):
|
|||||||
if migrate_engine.name == "mysql":
|
if migrate_engine.name == "mysql":
|
||||||
tables = ['meter', 'user', 'resource', 'project', 'source',
|
tables = ['meter', 'user', 'resource', 'project', 'source',
|
||||||
'sourceassoc']
|
'sourceassoc']
|
||||||
sql = "SET foreign_key_checks = 0;"
|
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||||
|
|
||||||
for table in tables:
|
for table in tables:
|
||||||
sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
|
migrate_engine.execute(
|
||||||
sql += "SET foreign_key_checks = 1;"
|
"ALTER TABLE %s CONVERT TO CHARACTER SET utf8" % table)
|
||||||
sql += ("ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" %
|
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||||
migrate_engine.url.database)
|
migrate_engine.execute(
|
||||||
migrate_engine.execute(sql)
|
"ALTER DATABASE %s DEFAULT CHARACTER SET utf8" %
|
||||||
|
migrate_engine.url.database)
|
||||||
|
|
||||||
|
|
||||||
def downgrade(migrate_engine):
|
def downgrade(migrate_engine):
|
||||||
@ -33,11 +34,12 @@ def downgrade(migrate_engine):
|
|||||||
if migrate_engine.name == "mysql":
|
if migrate_engine.name == "mysql":
|
||||||
tables = ['meter', 'user', 'resource', 'project', 'source',
|
tables = ['meter', 'user', 'resource', 'project', 'source',
|
||||||
'sourceassoc']
|
'sourceassoc']
|
||||||
sql = "SET foreign_key_checks = 0;"
|
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||||
|
|
||||||
for table in tables:
|
for table in tables:
|
||||||
sql += "ALTER TABLE %s CONVERT TO CHARACTER SET latin1;" % table
|
migrate_engine.execute(
|
||||||
sql += "SET foreign_key_checks = 1;"
|
"ALTER TABLE %s CONVERT TO CHARACTER SET latin1" % table)
|
||||||
sql += ("ALTER DATABASE %s DEFAULT CHARACTER SET latin1;" %
|
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||||
migrate_engine.url.database)
|
migrate_engine.execute(
|
||||||
migrate_engine.execute(sql)
|
"ALTER DATABASE %s DEFAULT CHARACTER SET latin1" %
|
||||||
|
migrate_engine.url.database)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user