From: malexander Date: Wed, 8 Dec 2021 19:12:23 +0000 (+0000) Subject: lp-1942645 term name uniqueness X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e9cd485f9d9aac2f72c94a9a8e777905517baed6;p=Evergreen.git 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 --- diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 2002113b99..b62dc761e4 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1147,10 +1147,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;