Fix oversight when creating a new database
This commit is contained in:
@@ -4,13 +4,8 @@ import time
|
||||
import re
|
||||
import os
|
||||
|
||||
def getVersion(db):
|
||||
cursor = db.execute('PRAGMA user_version')
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
def update(saveddata_engine):
|
||||
dbVersion = getVersion(saveddata_engine)
|
||||
|
||||
def getAppVersion():
|
||||
# calculate app version based on upgrade files we have
|
||||
appVersion = 0
|
||||
for fname in os.listdir(os.path.join(os.path.dirname(__file__), "migrations")):
|
||||
m = re.match("^upgrade(?P<index>\d+)\.py$", fname)
|
||||
@@ -18,6 +13,15 @@ def update(saveddata_engine):
|
||||
continue
|
||||
index = int(m.group("index"))
|
||||
appVersion = max(appVersion, index)
|
||||
return appVersion
|
||||
|
||||
def getVersion(db):
|
||||
cursor = db.execute('PRAGMA user_version')
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
def update(saveddata_engine):
|
||||
dbVersion = getVersion(saveddata_engine)
|
||||
appVersion = getAppVersion()
|
||||
|
||||
if dbVersion == appVersion:
|
||||
return
|
||||
|
||||
@@ -55,4 +55,4 @@ 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)
|
||||
eos.db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
|
||||
|
||||
Reference in New Issue
Block a user