From e1a091535e454838f5a2409860c4d8172d7c9699 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Nov 2024 08:45:28 +0100 Subject: [PATCH] refactor: refs #7920 Fix version --- .../11342-crimsonDendro/00-itemShelving.sql | 18 ++---------------- .../11342-crimsonDendro/01-itemShelving.sql | 2 ++ .../11342-crimsonDendro/01-itemShelvingLog.sql | 14 -------------- .../11342-crimsonDendro/02-itemShelving.sql | 3 +++ .../11342-crimsonDendro/03-itemShelving.sql | 4 ++++ .../11342-crimsonDendro/04-itemShelvingLog.sql | 6 ++++++ .../11342-crimsonDendro/05-itemShelvingLog.sql | 1 + .../11342-crimsonDendro/06-itemShelvingLog.sql | 5 +++++ 8 files changed, 23 insertions(+), 30 deletions(-) create mode 100644 db/versions/11342-crimsonDendro/01-itemShelving.sql delete mode 100644 db/versions/11342-crimsonDendro/01-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/02-itemShelving.sql create mode 100644 db/versions/11342-crimsonDendro/03-itemShelving.sql create mode 100644 db/versions/11342-crimsonDendro/04-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/05-itemShelvingLog.sql create mode 100644 db/versions/11342-crimsonDendro/06-itemShelvingLog.sql diff --git a/db/versions/11342-crimsonDendro/00-itemShelving.sql b/db/versions/11342-crimsonDendro/00-itemShelving.sql index a7b137ca5..4d083bf97 100644 --- a/db/versions/11342-crimsonDendro/00-itemShelving.sql +++ b/db/versions/11342-crimsonDendro/00-itemShelving.sql @@ -2,19 +2,5 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelving (PRIMARY KEY (id)) ENGINE = MEMORY SELECT ish.id, s.id shelvingFk - FROM vn.shelving s - JOIN vn.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 vn.itemShelving ish - JOIN tmp.tItemShelving tish ON tish.id = ish.id - SET ish.shelvingFk = tish.shelvingFk; - -DROP TEMPORARY TABLE tmp.tItemShelving; - -ALTER TABLE vn.itemShelving - ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) - ON DELETE RESTRICT - ON UPDATE CASCADE; + FROM vn.itemShelving ish + JOIN vn.shelving s ON s.code = ish.shelvingFk COLLATE utf8mb3_unicode_ci; diff --git a/db/versions/11342-crimsonDendro/01-itemShelving.sql b/db/versions/11342-crimsonDendro/01-itemShelving.sql new file mode 100644 index 000000000..23099ac6b --- /dev/null +++ b/db/versions/11342-crimsonDendro/01-itemShelving.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2, + MODIFY COLUMN shelvingFk int(11) NOT NULL; diff --git a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql deleted file mode 100644 index bcf217cfc..000000000 --- a/db/versions/11342-crimsonDendro/01-itemShelvingLog.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT ishl.id, s.id shelvingFk - FROM vn.shelving s - JOIN vn.itemShelvingLog ishl ON ishl.shelvingFk = s.code COLLATE utf8mb3_unicode_ci; - -ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; - -UPDATE vn.itemShelvingLog ishl - JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id - SET ishl.shelvingFk = tishl.shelvingFk; - -DROP TEMPORARY TABLE tmp.tItemShelvingLog; diff --git a/db/versions/11342-crimsonDendro/02-itemShelving.sql b/db/versions/11342-crimsonDendro/02-itemShelving.sql new file mode 100644 index 000000000..9d0e65d0b --- /dev/null +++ b/db/versions/11342-crimsonDendro/02-itemShelving.sql @@ -0,0 +1,3 @@ +UPDATE vn.itemShelving ish + JOIN tmp.tItemShelving tish ON tish.id = ish.id + SET ish.shelvingFk = tish.shelvingFk; \ No newline at end of file diff --git a/db/versions/11342-crimsonDendro/03-itemShelving.sql b/db/versions/11342-crimsonDendro/03-itemShelving.sql new file mode 100644 index 000000000..cb9825bfc --- /dev/null +++ b/db/versions/11342-crimsonDendro/03-itemShelving.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.itemShelving + ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql new file mode 100644 index 000000000..fbf997825 --- /dev/null +++ b/db/versions/11342-crimsonDendro/04-itemShelvingLog.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT ishl.id, s.id shelvingFk + FROM vn.itemShelvingLog ishl + JOIN vn.shelving s ON s.code = ishl.shelvingFk COLLATE utf8mb3_unicode_ci; diff --git a/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql new file mode 100644 index 000000000..88daedc36 --- /dev/null +++ b/db/versions/11342-crimsonDendro/05-itemShelvingLog.sql @@ -0,0 +1 @@ +ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL; diff --git a/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql new file mode 100644 index 000000000..3ebe32d7f --- /dev/null +++ b/db/versions/11342-crimsonDendro/06-itemShelvingLog.sql @@ -0,0 +1,5 @@ +UPDATE vn.itemShelvingLog ishl + JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id + SET ishl.shelvingFk = tishl.shelvingFk; + +DROP TEMPORARY TABLE tmp.tItemShelvingLog;