From 1e16fda5698c91e6892b58c41fb46bd4aa66f7d7 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 30 Sep 2017 16:33:57 +0200 Subject: [PATCH] Try to make mysql migration saner --- .../migrations/0010_delete_old_player_tables.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/evennia/typeclasses/migrations/0010_delete_old_player_tables.py b/evennia/typeclasses/migrations/0010_delete_old_player_tables.py index 07fd808000..dffdb38eef 100644 --- a/evennia/typeclasses/migrations/0010_delete_old_player_tables.py +++ b/evennia/typeclasses/migrations/0010_delete_old_player_tables.py @@ -22,17 +22,15 @@ def _drop_table(db_cursor, table_name): if _table_exists(db_cursor, table_name): if _ENGINE == "django.db.backends.mysql": - sql_drop = "SET FOREIGN_KEY_CHECKS=0;"\ - "DROP TABLE {table};"\ - "SET FOREIGN_KEY_CHECKS=1;".format(table=table_name) + db_cursor.execute("SET FOREIGN_KEY_CHECKS=0;") + db_cursor.execute("DROP TABLE {table};".format(table=table_name)) + db_cursor.execute("SET FOREIGN_KEY_CHECKS=1;") elif _ENGINE == "postgresql_psycopg2": - sql_drop = "ALTER TABLE {table} DISABLE TRIGGER ALL;"\ - "DROP TABLE {table};"\ - "ALTER TABLE {table} ENABLE TRIGGER ALL;".format(table=table_name) + db_cursor.execute("ALTER TABLE {table} DISABLE TRIGGER ALL;".format(table=table_name)) + db_cursor.execute("DROP TABLE {table};".format(table=table_name)) + db_cursor.execute("ALTER TABLE {table} ENABLE TRIGGER ALL;".format(table=table_name)) else: # sqlite3, other databases - sql_drop = "DROP TABLE {table};".format(table=table_name) - - db_cursor.execute(sql_drop) + db_cursor.execute("DROP TABLE {table};".format(table=table_name)) def drop_tables(apps, schema_migrator):