PyMySQL 0.8.0 compat fix

In PyMySQL the "MULTI_STATEMENT" flag has been disabled
by default. (see PyMySQL/PyMySQL#590 )

Migration 98 had a single string with multiple statements
ran in a single execution.

Moving this to multiple executions of the same statements
allows the migration to succeed with the new behaviour.

Caused-By: PyMySQL/PyMySQL@c0aa317940

Change-Id: I5f6d92f695c4c5830b8595b0cecbbafb426470a1
This commit is contained in:
Graham Hayes 2018-01-05 14:03:53 +00:00
parent 06858e2baf
commit 80dc905a86
No known key found for this signature in database
GPG Key ID: 1B263DC59F4AEFD5
1 changed files with 7 additions and 6 deletions

View File

@ -25,9 +25,10 @@ def upgrade(migrate_engine):
if migrate_engine.name != "mysql":
return
sql = """SET foreign_key_checks = 0;
ALTER TABLE service_statuses CONVERT TO CHARACTER SET utf8;
SET foreign_key_checks = 1;
ALTER DATABASE %s DEFAULT CHARACTER SET utf8;
""" % migrate_engine.url.database
migrate_engine.execute(sql)
migrate_engine.execute("SET foreign_key_checks = 0;")
migrate_engine.execute(
"ALTER TABLE service_statuses CONVERT TO CHARACTER SET utf8;")
migrate_engine.execute("SET foreign_key_checks = 1;")
migrate_engine.execute(
"ALTER DATABASE %s DEFAULT CHARACTER SET utf8;"
% migrate_engine.url.database)