Correct migrations to not re-remove fields.
This commit is contained in:
parent
c1326eaf23
commit
594500c4c7
5 changed files with 123 additions and 54 deletions
|
|
@ -2,7 +2,17 @@
|
|||
# Generated by Django 1.11.2 on 2017-07-06 20:41
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
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
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
@ -11,9 +21,14 @@ class Migration(migrations.Migration):
|
|||
('scripts', '0010_auto_20170705_1736'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='scriptdb',
|
||||
name='db_account',
|
||||
),
|
||||
]
|
||||
db_cursor = connection.cursor()
|
||||
|
||||
if not _table_exists(db_cursor, 'scripts_scriptdb_db_player'):
|
||||
operations = []
|
||||
else:
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='scriptdb',
|
||||
name='db_player',
|
||||
),
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue