adding a check in the upgrade script for a non-existent selection_ou and changing... user/rogan/lp2011434_selction_ou_fkey
authorRogan Hamby <rogan.hamby@gmail.com>
Wed, 15 Mar 2023 12:07:38 +0000 (08:07 -0400)
committerRogan Hamby <rogan.hamby@gmail.com>
Wed, 15 Mar 2023 12:07:38 +0000 (08:07 -0400)
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql

index 728ed35..2c8d2ee 100644 (file)
@@ -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;