LP#1902939: name uniqueness should be per-district
authorChris Sharp <csharp@georgialibraries.org>
Wed, 29 Sep 2021 14:18:10 +0000 (10:18 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Fri, 5 Nov 2021 16:37:37 +0000 (12:37 -0400)
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.student_cards.sql

index 6dc5aa1..3e491e1 100644 (file)
@@ -19,7 +19,7 @@ CREATE TABLE student_card.district (
 CREATE TABLE student_card.school (
     id                  SERIAL PRIMARY KEY,
     district_id         INTEGER NOT NULL REFERENCES student_card.district (id),
-    name                TEXT NOT NULL UNIQUE,
+    name                TEXT NOT NULL,
     state_id            INTEGER NOT NULL, -- school ID per the State of Georgia
     grades              TEXT,
     addr_street_1       TEXT,
@@ -31,7 +31,8 @@ CREATE TABLE student_card.school (
     eg_perm_group       INTEGER NOT NULL REFERENCES permission.grp_tree (id),
     home_ou             INTEGER NOT NULL REFERENCES actor.org_unit (id)
 );
-CREATE UNIQUE INDEX student_card_school_state_id_idx ON student_card.school (district_id, state_id);
+CREATE UNIQUE INDEX student_card_school_state_id_once_per_district_idx ON student_card.school (district_id, state_id);
+CREATE UNIQUE INDEX student_card_school_name_once_per_district_idx ON student_card.school (district_id, name);
 
 CREATE TABLE student_card.import (
     id                  SERIAL PRIMARY KEY,
@@ -42,7 +43,7 @@ CREATE TABLE student_card.import (
 );
 
 INSERT INTO permission.perm_list ( id, code, description ) VALUES
- ( 628, 'ADMIN_STUDENT_CARDS', oils_i18n_gettext(628,
+ ( 636, 'ADMIN_STUDENT_CARDS', oils_i18n_gettext(636,
     'Modify student card settings', 'ppl', 'description'));
 
 INSERT INTO config.org_unit_setting_type