In acq.lineitem_alert_text: add owning_lib column. Also make the
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Feb 2010 15:12:14 +0000 (15:12 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Feb 2010 15:12:14 +0000 (15:12 +0000)
UNIQUE constraint apply to code + owning_lib, not just code.

M    Open-ILS/src/sql/Pg/200.schema.acq.sql
M    Open-ILS/src/sql/Pg/002.schema.config.sql
A    Open-ILS/src/sql/Pg/upgrade/0161.schema.acq.alert-text-org.sql
M    Open-ILS/examples/fm_IDL.xml

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15533 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/upgrade/0161.schema.acq.alert-text-org.sql [new file with mode: 0644]

index ca211a8..f9b1ae3 100644 (file)
@@ -5039,8 +5039,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Alert Text ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Code" name="code" reporter:datatype="text"/>
                        <field reporter:label="Description" name="description" reporter:datatype="text"/>
+                       <field reporter:label="Owning Library" name="owning_lib" reporter:datatype="link"/>
                </fields>
                <links>
+                       <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                </permacrud>
index 3136273..fb3dffe 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0160'); --Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0161'); --Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index b75bb37..b1ce462 100644 (file)
@@ -423,8 +423,12 @@ CREATE INDEX li_selector_idx  ON acq.lineitem ( selector );
 
 CREATE TABLE acq.lineitem_alert_text (
     id               SERIAL         PRIMARY KEY,
-    code             TEXT           UNIQUE NOT NULL,
-    description      TEXT
+    code             TEXT           NOT NULL,
+    description      TEXT,
+       owning lib       INT            NOT NULL
+                                       REFERENCES actor.org_unit(id)
+                                       DEFERRABLE INITIALLY DEFERRED,
+       CONSTRAINT alert_one_code_per_org UNIQUE (code, owning_lib)
 );
 
 CREATE TABLE acq.lineitem_note (
diff --git a/Open-ILS/src/sql/Pg/upgrade/0161.schema.acq.alert-text-org.sql b/Open-ILS/src/sql/Pg/upgrade/0161.schema.acq.alert-text-org.sql
new file mode 100644 (file)
index 0000000..ba2200f
--- /dev/null
@@ -0,0 +1,16 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0161'); -- Scott McKellar
+
+ALTER TABLE acq.lineitem_alert_text
+       ADD COLUMN owning_lib INT NOT NULL
+                                 REFERENCES actor.org_unit(id)
+                                 DEFERRABLE INITIALLY DEFERRED;
+
+ALTER TABLE acq.lineitem_alert_text
+       DROP CONSTRAINT lineitem_alert_text_code_key;
+
+ALTER TABLE acq.lineitem_alert_text
+       ADD CONSTRAINT alert_one_code_per_org UNIQUE (code, owning_lib);
+
+COMMIT;