From a7314d01520a4a4cef75259bc945bb4bce3a24c1 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Mon, 13 Mar 2023 09:16:48 -0400 Subject: [PATCH] adding a foreign key check for selction_ou on action.hold_request --- Open-ILS/src/sql/Pg/090.schema.action.sql | 2 +- .../src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 711269e245..56db9e9768 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -471,7 +471,7 @@ CREATE TABLE action.hold_request ( request_lib INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, requestor INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, usr INT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, - selection_ou INT NOT NULL, + selection_ou INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, selection_depth INT NOT NULL DEFAULT 0, pickup_lib INT NOT NULL REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED, hold_type TEXT REFERENCES config.hold_type (hold_type) DEFERRABLE INITIALLY DEFERRED, 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 new file mode 100644 index 0000000000..728ed356ec --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql @@ -0,0 +1,7 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); + +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