From 5a134668da73d8a7205856248d2b40b2e14de8fa Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:04:47 +0100 Subject: [PATCH] refactor: refs #7920 itemShelvingLog --- .../{00-firstScript.sql => 00-itemShelving.sql} | 6 +++--- .../11342-crimsonDendro/01-itemShelvingLog.sql | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) rename db/versions/11342-crimsonDendro/{00-firstScript.sql => 00-itemShelving.sql} (73%) create mode 100644 db/versions/11342-crimsonDendro/01-itemShelvingLog.sql diff --git a/db/versions/11342-crimsonDendro/00-firstScript.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql similarity index 73% rename from db/versions/11342-crimsonDendro/00-firstScript.sql rename to db/versions/11342-crimsonDendro/00-itemShelving.sql index 56bea2c03..7a173e203 100644 --- a/db/versions/11342-crimsonDendro/00-firstScript.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -3,14 +3,14 @@ CREATE OR REPLACE TEMPORARY TABLE tItemShelving ENGINE = MEMORY SELECT ish.id, s.id shelvingFk FROM shelving s - JOIN itemShelving ish ON ish.shelvingFk = s.code; + JOIN itemShelving ish ON ish.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, MODIFY COLUMN shelvingFk int(11) NOT NULL; UPDATE itemShelving ish - JOIN tItemShelving tis ON tis.id = ish.id - SET ish.shelvingFk = tis.shelvingFk; + JOIN tItemShelving tish ON tish.id = ish.id + SET ish.shelvingFk = tish.shelvingFk; DROP TEMPORARY TABLE tItemShelving; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql new file mode 100644 index 000000000..05f04b5ff --- /dev/null +++ b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql @@ -0,0 +1,14 @@ +CREATE OR REPLACE TEMPORARY TABLE tItemShelvingLog + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT ishl.id, s.id shelvingFk + FROM shelving s + JOIN itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; + +ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; + +UPDATE itemShelvingLog ishl + JOIN tItemShelvingLog tishl ON tishl.id = ishl.id + SET ishl.shelvingFk = tishl.shelvingFk; + +DROP TEMPORARY TABLE tItemShelvingLog;