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
<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>
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,
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 (
--- /dev/null
+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;