From d1345fc71eaf96b1ee55310126d2adae74b7f012 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Wed, 24 Jun 2020 15:09:51 -0400 Subject: [PATCH 1/2] 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 From 433c9555bf620e7ae948f754d81ac4957da6b837 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Wed, 24 Jun 2020 15:18:43 -0400 Subject: [PATCH 2/2] Removed the util function - this would actually break older migrations if we added things that didn't exist in future iterations. Each migration should be self-contained --- eos/db/migrations/upgrade40.py | 6 ++++-- eos/db/migrations/utils.py | 15 --------------- 2 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 eos/db/migrations/utils.py diff --git a/eos/db/migrations/upgrade40.py b/eos/db/migrations/upgrade40.py index a09ed756a..597e7934f 100644 --- a/eos/db/migrations/upgrade40.py +++ b/eos/db/migrations/upgrade40.py @@ -5,7 +5,6 @@ Imports all item conversions since Migration 28 and runs them against module.bas 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 @@ -13,4 +12,7 @@ from .upgrade39 import CONVERSIONS as u39 def upgrade(saveddata_engine): for conversions in [u36, u37, u38, u39]: - convert_modules(saveddata_engine, conversions) + for replacement_item, list in conversions.items(): + for retired_item in list: + saveddata_engine.execute('UPDATE "modules" SET "baseItemID" = ? WHERE "baseItemID" = ?', + (replacement_item, retired_item)) diff --git a/eos/db/migrations/utils.py b/eos/db/migrations/utils.py deleted file mode 100644 index 51b26ebe4..000000000 --- a/eos/db/migrations/utils.py +++ /dev/null @@ -1,15 +0,0 @@ -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