Change constraint on acq.provider. Instead of making code unique
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 24 Aug 2009 17:49:26 +0000 (17:49 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 24 Aug 2009 17:49:26 +0000 (17:49 +0000)
by itself, make code + owner unique.

To change an existing table:

ALTER TABLE acq.provider
DROP CONSTRAINT provider_code_key;

ALTER TABLE acq.provider
ALTER COLUMN code SET NOT NULL;

ALTER TABLE acq.provider
ADD CONSTRAINT code_once_per_owner
UNIQUE (code, owner);

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

Open-ILS/src/sql/Pg/200.schema.acq.sql

index bacce5d..131347d 100644 (file)
@@ -34,9 +34,10 @@ CREATE TABLE acq.provider (
     name                TEXT    NOT NULL,
     owner               INT     NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
     currency_type       TEXT    NOT NULL REFERENCES acq.currency_type (code) DEFERRABLE INITIALLY DEFERRED,
-    code                TEXT    UNIQUE,
+    code                TEXT    NOT NULL,
     holding_tag         TEXT,
-    CONSTRAINT provider_name_once_per_owner UNIQUE (name,owner)
+    CONSTRAINT provider_name_once_per_owner UNIQUE (name,owner),
+       CONSTRAINT code_once_per_owner UNIQUE (code, owner)
 );
 
 CREATE TABLE acq.provider_holding_subfield_map (