Update some migrations to consider new schema (#1185)

* Update some migrations to consider new schema

* tox
This commit is contained in:
Ryan Holmes
2017-05-20 02:44:26 -04:00
committed by GitHub
parent fbf455c9fe
commit 2e2303c9aa
2 changed files with 23 additions and 19 deletions

View File

@@ -16,23 +16,27 @@ def upgrade(saveddata_engine):
JOIN wings w on w.ID = s.wingID
JOIN gangs g on g.ID = w.gangID
"""
try:
results = saveddata_session.execute(sql)
results = saveddata_session.execute(sql)
inserts = []
inserts = []
for row in results:
boosted = row["boostedFit"]
types = ("squad", "wing", "gang")
for x in types:
value = row["{}Boost".format(x)]
if value is None:
continue
for row in results:
boosted = row["boostedFit"]
types = ("squad", "wing", "gang")
for x in types:
value = row["{}Boost".format(x)]
if value is None:
continue
inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
try:
saveddata_session.execute(commandFits_table.insert(),
{"boosterID": value, "boostedID": boosted, "active": 1})
except Exception:
pass
saveddata_session.commit()
inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
try:
saveddata_session.execute(commandFits_table.insert(),
{"boosterID": value, "boostedID": boosted, "active": 1})
except Exception:
pass
saveddata_session.commit()
except:
# Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version
# If it does, simply fail. Fleet data migration isn't critically important here
pass

View File

@@ -7,5 +7,5 @@ Overwrites damage profile 0 to reset bad uniform values (bad values set with bug
def upgrade(saveddata_engine):
saveddata_engine.execute('DELETE FROM damagePatterns WHERE name LIKE ? OR ID LIKE ?', ("Uniform", "1"))
saveddata_engine.execute('INSERT INTO damagePatterns VALUES (?, ?, ?, ?, ?, ?, ?)',
(1, "Uniform", 25, 25, 25, 25, None))
saveddata_engine.execute('INSERT INTO damagePatterns VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
(1, "Uniform", 25, 25, 25, 25, None, None, None))