From a11ce4760ec45d6d914980bf5604bd3d82cb370b Mon Sep 17 00:00:00 2001 From: malexander Date: Wed, 8 Dec 2021 19:12:23 +0000 Subject: [PATCH] lp-1942645 term name uniqueness dropped name uniqueness between orgs, added constraint to owning lib and name Includes syntax corrections from Martha Driscoll -- thank you, Martha! Signed-off-by: malexander Signed-off-by: Beth Willis Signed-off-by: Jane Sandberg --- Open-ILS/src/sql/Pg/040.schema.asset.sql | 5 +++-- .../XXXX.schema.update_course_module_term_constraints.sql | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.update_course_module_term_constraints.sql diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 44de65b0dc..e2692381ca 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1132,10 +1132,11 @@ CREATE TABLE asset.course_module_course_materials ( CREATE TABLE asset.course_module_term ( id SERIAL PRIMARY KEY, - name TEXT UNIQUE NOT NULL, + name TEXT NOT NULL, owning_lib INT REFERENCES actor.org_unit (id), start_date TIMESTAMP WITH TIME ZONE, - end_date TIMESTAMP WITH TIME ZONE + end_date TIMESTAMP WITH TIME ZONE, + CONSTRAINT cmt_once_per_owning_lib UNIQUE (owning_lib, name) ); CREATE TABLE asset.course_module_term_course_map ( diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.update_course_module_term_constraints.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.update_course_module_term_constraints.sql new file mode 100644 index 0000000000..e4cbfe7b15 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.update_course_module_term_constraints.sql @@ -0,0 +1,11 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE asset.course_module_term + DROP CONSTRAINT course_module_term_name_key; + +ALTER TABLE asset.course_module_term + ADD CONSTRAINT cmt_once_per_owning_lib UNIQUE (owning_lib, name); + +COMMIT; -- 2.11.0