diff --git a/eos/db/migration.py b/eos/db/migration.py index 0b8e5fd2b..9dafb52ac 100755 --- a/eos/db/migration.py +++ b/eos/db/migration.py @@ -2,6 +2,8 @@ import sqlalchemy def update(saveddata_engine): checkPriceFailures(saveddata_engine) + checkApiDefaultChar(saveddata_engine) + def checkPriceFailures(saveddata_engine): # Check if we have 'failed' column @@ -18,3 +20,22 @@ def checkPriceFailures(saveddata_engine): except sqlalchemy.exc.DatabaseError: pass + +def checkApiDefaultChar(saveddata_engine): + try: + saveddata_engine.execute("SELECT * FROM characters LIMIT 1") + # If table doesn't exist, it means we're doing everything from scratch + # and sqlalchemy will process everything as needed + except sqlalchemy.exc.DatabaseError: + pass + # If not, we're running on top of existing DB + else: + # Check that we have columns + try: + saveddata_engine.execute("SELECT defaultChar, chars FROM characters LIMIT 1") + # If we don't, create them + # This is ugly as hell, but we can't use proper migrate packages as it + # will require us to rebuild skeletons, including mac + except sqlalchemy.exc.DatabaseError: + saveddata_engine.execute("ALTER TABLE characters ADD COLUMN defaultChar INTEGER;") + saveddata_engine.execute("ALTER TABLE characters ADD COLUMN chars VARCHAR;")