adding a foreign key check for selction_ou on action.hold_request
authorRogan Hamby <rogan.hamby@gmail.com>
Mon, 13 Mar 2023 13:16:48 +0000 (09:16 -0400)
committerRogan Hamby <rogan.hamby@gmail.com>
Mon, 13 Mar 2023 13:16:48 +0000 (09:16 -0400)
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.function-selection-ou-fkey.sql [new file with mode: 0644]

index 711269e..56db9e9 100644 (file)
@@ -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 (file)
index 0000000..728ed35
--- /dev/null
@@ -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;