Add a sanity check for comm migration
This commit is contained in:
parent
f45bd4921d
commit
c1326eaf23
1 changed files with 55 additions and 38 deletions
|
|
@ -2,7 +2,17 @@
|
||||||
# Generated by Django 1.11.2 on 2017-07-05 17:26
|
# Generated by Django 1.11.2 on 2017-07-05 17:26
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models, connection
|
||||||
|
from django.db import OperationalError
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
@ -12,6 +22,13 @@ class Migration(migrations.Migration):
|
||||||
('comms', '0012_merge_20170617_2017'),
|
('comms', '0012_merge_20170617_2017'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
db_cursor = connection.cursor()
|
||||||
|
|
||||||
|
if not _table_exists(db_cursor, 'comms_msg_db_hide_from_players'):
|
||||||
|
# OBS - this is run BEFORE migrations are run!
|
||||||
|
# not a migration of an existing database
|
||||||
|
operations = []
|
||||||
|
else:
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='channeldb',
|
model_name='channeldb',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue