Merge "Issue one SQL statement per execute() call"
This commit is contained in:
commit
6a19c940fb
@ -18,14 +18,15 @@ def upgrade(migrate_engine):
|
||||
if migrate_engine.name == "mysql":
|
||||
tables = ['meter', 'user', 'resource', 'project', 'source',
|
||||
'sourceassoc']
|
||||
sql = "SET foreign_key_checks = 0;"
|
||||
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||
|
||||
for table in tables:
|
||||
sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
|
||||
sql += "SET foreign_key_checks = 1;"
|
||||
sql += ("ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" %
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE %s CONVERT TO CHARACTER SET utf8" % table)
|
||||
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||
migrate_engine.execute(
|
||||
"ALTER DATABASE %s DEFAULT CHARACTER SET utf8" %
|
||||
migrate_engine.url.database)
|
||||
migrate_engine.execute(sql)
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
@ -33,11 +34,12 @@ def downgrade(migrate_engine):
|
||||
if migrate_engine.name == "mysql":
|
||||
tables = ['meter', 'user', 'resource', 'project', 'source',
|
||||
'sourceassoc']
|
||||
sql = "SET foreign_key_checks = 0;"
|
||||
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||
|
||||
for table in tables:
|
||||
sql += "ALTER TABLE %s CONVERT TO CHARACTER SET latin1;" % table
|
||||
sql += "SET foreign_key_checks = 1;"
|
||||
sql += ("ALTER DATABASE %s DEFAULT CHARACTER SET latin1;" %
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE %s CONVERT TO CHARACTER SET latin1" % table)
|
||||
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||
migrate_engine.execute(
|
||||
"ALTER DATABASE %s DEFAULT CHARACTER SET latin1" %
|
||||
migrate_engine.url.database)
|
||||
migrate_engine.execute(sql)
|
||||
|
Loading…
x
Reference in New Issue
Block a user