From 1b810d72f87b351030d96ba3d0ead0f3ea34d7b5 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Wed, 15 Mar 2023 08:07:38 -0400 Subject: [PATCH] adding a check in the upgrade script for a non-existent selection_ou and changing it to the request_lib --- .../src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql index 728ed356ec..2c8d2ee35d 100644 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql @@ -2,6 +2,14 @@ BEGIN; SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); +UPDATE action.hold_request +SET selection_ou = request_lib +WHERE id IN ( + SELECT ahr.id FROM action.hold_request ahr + LEFT JOIN actor.org_unit aou ON aou.id = ahr.selection_ou + WHERE aou.id IS NULL +); + ALTER TABLE action.hold_request ADD CONSTRAINT hold_request_selection_ou_fkey FOREIGN KEY (selection_ou) REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED; COMMIT; -- 2.11.0