Skip to content

Commit

Permalink
PyMySQL 0.8.0 compat fix
Browse files Browse the repository at this point in the history
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@c0aa317

Change-Id: I5f6d92f695c4c5830b8595b0cecbbafb426470a1
  • Loading branch information
grahamhayes committed Jan 5, 2018
1 parent 53d6dc0 commit c1a77a3
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -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)

0 comments on commit c1a77a3

Please sign in to comment.