Introduce new migration procedure.

This creates a new migration module that include upgrade logic files, one file for each DB version. It should be noted that this will not support downgrades (the previous method didn't really support them either)
This commit is contained in:
blitzmann
2014-09-28 00:14:10 -04:00
parent 4ea2636788
commit 3054ac9d90
6 changed files with 131 additions and 73 deletions

11
pyfa.py
View File

@@ -84,6 +84,7 @@ if __name__ == "__main__":
import os.path
import eos.db
import eos.db.migration as migration
import service.prefetch
from gui.mainFrame import MainFrame
@@ -91,7 +92,15 @@ if __name__ == "__main__":
if not os.path.exists(config.savePath):
os.mkdir(config.savePath)
eos.db.saveddata_meta.create_all()
if os.path.isfile(config.saveDB):
# If database exists, run migration after init'd database
eos.db.saveddata_meta.create_all()
migration.update(eos.db.saveddata_engine)
else:
# If database does not exist, do not worry about migration. Simply
# create and set version
eos.db.saveddata_meta.create_all()
eos.db.saveddata_engine.execute('PRAGMA user_version = %d'%config.dbversion)
pyfa = wx.App(False)
MainFrame()