Add migration to finally remove the last playerdb_ tables

This commit is contained in:
Griatch 2017-07-13 20:59:32 +02:00
parent 6d846c6c82
commit 58b6f41b7b

View file

@ -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)
]