From 64351aa7c4a1dab610da45d0141ccf1474fe074c Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 15 May 2023 09:54:22 -0400 Subject: [PATCH] cascade --- Open-ILS/src/sql/Pg/005.schema.actors.sql | 2 +- .../sql/Pg/upgrade/YYYY.schema.org_unit_custom_node.sql | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.schema.org_unit_custom_node.sql diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 1c6fb9d27f..6a26f47683 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -758,7 +758,7 @@ CREATE TABLE actor.org_unit_custom_tree_node ( id SERIAL PRIMARY KEY, tree INTEGER REFERENCES actor.org_unit_custom_tree (id) DEFERRABLE INITIALLY DEFERRED, org_unit INTEGER NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, - parent_node INTEGER REFERENCES actor.org_unit_custom_tree_node (id) DEFERRABLE INITIALLY DEFERRED, + parent_node INTEGER REFERENCES actor.org_unit_custom_tree_node (id) CASCADE DEFERRABLE INITIALLY DEFERRED, sibling_order INTEGER NOT NULL DEFAULT 0, CONSTRAINT aouctn_once_per_org UNIQUE (tree, org_unit) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.org_unit_custom_node.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.org_unit_custom_node.sql new file mode 100644 index 0000000000..66a2020dbe --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.org_unit_custom_node.sql @@ -0,0 +1,14 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE actor.org_unit_custom_tree_node +DROP CONSTRAINT org_unit_custom_tree_node_parent_node_fkey; + +ALTER TABLE actor.org_unit_custom_tree_node +ADD CONSTRAINT org_unit_custom_tree_node_parent_node_fkey +FOREIGN KEY (parent_node) +REFERENCES actor.org_unit_custom_tree_node(id) +ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; + +COMMIT; -- 2.11.0