Fixed migrations

This commit is contained in:
Frisk 2023-01-10 22:36:20 +01:00
parent a581bba757
commit caf44345c1
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
3 changed files with 6 additions and 5 deletions

View file

@ -11,6 +11,7 @@ from src.migrations.utils import return_example_file
logger = logging.getLogger("rcgcdw.migrations.1.13.1.1") logger = logging.getLogger("rcgcdw.migrations.1.13.1.1")
new_settings = settings.copy() new_settings = settings.copy()
def run(): def run():
if "event_appearance" not in settings: if "event_appearance" not in settings:
logger.info("Running migration 1.13.1.1") logger.info("Running migration 1.13.1.1")
@ -34,8 +35,8 @@ def run():
except KeyError: except KeyError:
logger.exception("Failed to migrate appearance embed.") logger.exception("Failed to migrate appearance embed.")
sys.exit(1) sys.exit(1)
shutil.copy(command_args.settings, command_args.settings+".{}.bak".format(int(time.time()))) shutil.copy(command_args.settings.name, "{}.{}.bak".format(command_args.settings.name, int(time.time())))
with open(command_args.settings, "w", encoding="utf-8") as new_write: with open(command_args.settings.name, "w", encoding="utf-8") as new_write:
new_write.write(json.dumps(new_settings, indent=4)) new_write.write(json.dumps(new_settings, indent=4))
load_settings() load_settings()
logger.info("Migration 1.13.1.1 has been successful.") logger.info("Migration 1.13.1.1 has been successful.")

View file

@ -30,8 +30,8 @@ def run():
sys.exit(1) sys.exit(1)
if change: if change:
logger.info("Running migration falsytypes") logger.info("Running migration falsytypes")
shutil.copy(command_args.settings, command_args.settings+".{}.bak".format(int(time.time()))) shutil.copy(command_args.settings.name, "{}.{}.bak".format(command_args.settings.name, int(time.time())))
with open(command_args.settings, "w", encoding="utf-8") as new_write: with open(command_args.settings.name, "w", encoding="utf-8") as new_write:
new_write.write(json.dumps(new_settings, indent=4)) new_write.write(json.dumps(new_settings, indent=4))
load_settings() load_settings()
logger.info("Migration falsytypes has been successful.") logger.info("Migration falsytypes has been successful.")

View file

@ -20,9 +20,9 @@
# You have been warned # You have been warned
import time, logging.config, requests, datetime, math, os.path, sys, importlib import time, logging.config, requests, datetime, math, os.path, sys, importlib
import src.misc import src.misc
import src.configloader import src.configloader
from src.migrations import *
from collections import defaultdict, Counter, OrderedDict from collections import defaultdict, Counter, OrderedDict
from src.argparser import command_args from src.argparser import command_args
from typing import Optional from typing import Optional