dbutils: version can now be left black to auto-upgrade to latest

This commit is contained in:
2023-04-15 00:13:04 -04:00
parent baa885f674
commit a416fb09e1
2 changed files with 29 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import yaml
import argparse
import logging
from core.config import CoreConfig
from core.data import Data
from os import path, mkdir, access, W_OK
@ -43,6 +44,7 @@ if __name__ == "__main__":
)
exit(1)
cfg.update({"database": {"loglevel": "info"}}) # Force it to be info if we're doing db work
data = Data(cfg)
@ -54,15 +56,14 @@ if __name__ == "__main__":
elif args.action == "upgrade" or args.action == "rollback":
if args.version is None:
data.logger.error("Must set game and version to migrate to")
exit(0)
data.logger.warn("No version set, upgrading to latest")
if args.game is None:
data.logger.info("No game set, upgrading core schema")
data.migrate_database("CORE", int(args.version), args.action)
data.logger.warn("No game set, upgrading core schema")
data.migrate_database("CORE", int(args.version) if args.version is not None else None, args.action)
else:
data.migrate_database(args.game, int(args.version), args.action)
data.migrate_database(args.game, int(args.version) if args.version is not None else None, args.action)
elif args.action == "autoupgrade":
data.autoupgrade()