mirror of
https://github.com/evennia/evennia.git
synced 2026-03-24 16:56:32 +01:00
Add migration to finally remove the last playerdb_ tables
This commit is contained in:
parent
6d846c6c82
commit
58b6f41b7b
1 changed files with 41 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.3 on 2017-07-13 18:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, OperationalError, connection
|
||||
|
||||
|
||||
def _table_exists(db_cursor, tablename):
|
||||
"Returns bool if table exists or not"
|
||||
sql_check_exists = "SELECT * from %s;" % tablename
|
||||
try:
|
||||
db_cursor.execute(sql_check_exists)
|
||||
return True
|
||||
except OperationalError:
|
||||
return False
|
||||
|
||||
|
||||
def _drop_table(db_cursor, table_name):
|
||||
if _table_exists(db_cursor, table_name):
|
||||
sql_drop = "DROP TABLE %s;" % table_name
|
||||
db_cursor.execute(sql_drop)
|
||||
|
||||
|
||||
def drop_tables(apps, schema_migrator):
|
||||
db_cursor = connection.cursor()
|
||||
_drop_table(db_cursor, "players_playerdb")
|
||||
_drop_table(db_cursor, "players_playerdb_db_attributes")
|
||||
_drop_table(db_cursor, "players_playerdb_db_tags")
|
||||
_drop_table(db_cursor, "players_playerdb_groups")
|
||||
_drop_table(db_cursor, "players_playerdb_user_permissions")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('typeclasses', '0009_rename_player_cmdsets_typeclasses'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(drop_tables)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue