MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / upgrade

Function upgrade

eos/db/migrations/upgrade17.py:8–46  ·  view source on GitHub ↗
(saveddata_engine)

Source from the content-addressed store, hash-verified

6
7
8def upgrade(saveddata_engine):
9 from eos.db import saveddata_session
10 from eos.db.saveddata.fit import commandFits_table
11
12 sql = """
13 SELECT sm.memberID as boostedFit, s.leaderID AS squadBoost, w.leaderID AS wingBoost, g.leaderID AS gangBoost
14 FROM squadmembers sm
15 JOIN squads s ON s.ID = sm.squadID
16 JOIN wings w on w.ID = s.wingID
17 JOIN gangs g on g.ID = w.gangID
18 """
19 try:
20 results = saveddata_session.execute(sql)
21
22 inserts = []
23
24 for row in results:
25 boosted = row["boostedFit"]
26 types = ("squad", "wing", "gang")
27 for x in types:
28 value = row["{}Boost".format(x)]
29 if value is None:
30 continue
31
32 inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
33 try:
34 saveddata_session.execute(commandFits_table.insert(),
35 {"boosterID": value, "boostedID": boosted, "active": 1})
36 except (KeyboardInterrupt, SystemExit):
37 raise
38 except Exception:
39 pass
40 saveddata_session.commit()
41 except (KeyboardInterrupt, SystemExit):
42 raise
43 except:
44 # Shouldn't fail unless you have updated database without the old fleet schema and manually modify the database version
45 # If it does, simply fail. Fleet data migration isn't critically important here
46 pass

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected