Merge "Issue one SQL statement per execute() call"

This commit is contained in:
Jenkins 2014-08-14 03:50:26 +00:00 committed by Gerrit Code Review
commit 6a19c940fb

View File

@ -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)