mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 09:46:32 +01:00
Try to make mysql migration saner
This commit is contained in:
parent
9f6f16fb7d
commit
1e16fda569
1 changed files with 7 additions and 9 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue