File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33def update (saveddata_engine ):
44 checkPriceFailures (saveddata_engine )
5+ checkApiDefaultChar (saveddata_engine )
6+
57
68def checkPriceFailures (saveddata_engine ):
79 # Check if we have 'failed' column
@@ -18,3 +20,22 @@ def checkPriceFailures(saveddata_engine):
1820 except sqlalchemy .exc .DatabaseError :
1921 pass
2022
23+
24+ def checkApiDefaultChar (saveddata_engine ):
25+ try :
26+ saveddata_engine .execute ("SELECT * FROM characters LIMIT 1" )
27+ # If table doesn't exist, it means we're doing everything from scratch
28+ # and sqlalchemy will process everything as needed
29+ except sqlalchemy .exc .DatabaseError :
30+ pass
31+ # If not, we're running on top of existing DB
32+ else :
33+ # Check that we have columns
34+ try :
35+ saveddata_engine .execute ("SELECT defaultChar, chars FROM characters LIMIT 1" )
36+ # If we don't, create them
37+ # This is ugly as hell, but we can't use proper migrate packages as it
38+ # will require us to rebuild skeletons, including mac
39+ except sqlalchemy .exc .DatabaseError :
40+ saveddata_engine .execute ("ALTER TABLE characters ADD COLUMN defaultChar INTEGER;" )
41+ saveddata_engine .execute ("ALTER TABLE characters ADD COLUMN chars VARCHAR;" )
You can’t perform that action at this time.
0 commit comments