From d1345fc71eaf96b1ee55310126d2adae74b7f012 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Wed, 24 Jun 2020 15:09:51 -0400 Subject: [PATCH] Fixes #2205 - runs conversions on `modules.baseItemID` since the creation of `baseItemID`. Also, centralized the function to convert modules so that in case we ever add other things that need to be converted, they are all in one spot. --- eos/db/migrations/upgrade40.py | 16 ++++++++++++++++ eos/db/migrations/utils.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 eos/db/migrations/upgrade40.py create mode 100644 eos/db/migrations/utils.py diff --git a/eos/db/migrations/upgrade40.py b/eos/db/migrations/upgrade40.py new file mode 100644 index 000000000..a09ed756a --- /dev/null +++ b/eos/db/migrations/upgrade40.py @@ -0,0 +1,16 @@ +""" +Migration 40 + +Imports all item conversions since Migration 28 and runs them against module.baseItemID. This column seems to have been +forgotten about since it's been added. + +""" +from. utils import convert_modules +from .upgrade36 import CONVERSIONS as u36 +from .upgrade37 import CONVERSIONS as u37 +from .upgrade38 import CONVERSIONS as u38 +from .upgrade39 import CONVERSIONS as u39 + +def upgrade(saveddata_engine): + for conversions in [u36, u37, u38, u39]: + convert_modules(saveddata_engine, conversions) diff --git a/eos/db/migrations/utils.py b/eos/db/migrations/utils.py new file mode 100644 index 000000000..51b26ebe4 --- /dev/null +++ b/eos/db/migrations/utils.py @@ -0,0 +1,15 @@ +def convert_modules(engine, conversions): + '''Converts modules based on tiericide conversion mappings. + + :param engine: + :param conversions: + :return: + ''' + for replacement_item, list in conversions.items(): + for retired_item in list: + engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', + (replacement_item, retired_item)) + engine.execute('UPDATE "modules" SET "baseItemID" = ? WHERE "baseItemID" = ?', + (replacement_item, retired_item)) + engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', + (replacement_item, retired_item)) \ No newline at end of file