(saveddata_engine)
| 18 | |
| 19 | |
| 20 | def update(saveddata_engine): |
| 21 | dbVersion = getVersion(saveddata_engine) |
| 22 | appVersion = getAppVersion() |
| 23 | |
| 24 | if dbVersion == appVersion: |
| 25 | return |
| 26 | |
| 27 | if dbVersion < appVersion: |
| 28 | # Automatically backup database |
| 29 | toFile = "%s/saveddata_migration_%d-%d_%s.db" % ( |
| 30 | config.savePath, |
| 31 | dbVersion, |
| 32 | appVersion, |
| 33 | time.strftime("%Y%m%d_%H%M%S")) |
| 34 | |
| 35 | shutil.copyfile(config.saveDB, toFile) |
| 36 | |
| 37 | for version in range(dbVersion, appVersion): |
| 38 | func = migrations.updates[version + 1] |
| 39 | if func: |
| 40 | pyfalog.info("Applying database update: {0}", version + 1) |
| 41 | func(saveddata_engine) |
| 42 | |
| 43 | # when all is said and done, set version to current |
| 44 | saveddata_engine.execute("PRAGMA user_version = {}".format(appVersion)) |
nothing calls this directly
no test coverage detected