Create two new tables: acq.distribution_formula
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 20 Mar 2009 12:42:01 +0000 (12:42 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 20 Mar 2009 12:42:01 +0000 (12:42 +0000)
and acq.distribution_formula_entry.

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

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

index c468173..6b82aba 100644 (file)
@@ -273,6 +273,30 @@ INSERT INTO acq.lineitem_marc_attr_definition ( code, description, xpath ) VALUE
 INSERT INTO acq.lineitem_marc_attr_definition ( code, description, xpath ) VALUES ('edition','Edition','//*[@tag="250"]/*[@code="a"][1]');
 
 
+CREATE TABLE acq.distribution_formula (
+       id              SERIAL PRIMARY KEY,
+       owner   INT NOT NULL
+                       REFERENCES actor.org_unit(id) DEFERRABLE INITIALLY DEFERRED,
+       name    TEXT NOT NULL,
+       skip_count      INT NOT NULL DEFAULT 0,
+       CONSTRAINT acqdf_name_once_per_owner UNIQUE (name, owner)
+);
+
+CREATE TABLE acq.distribution_formula_entry (
+       id                      SERIAL PRIMARY KEY,
+       formula         INTEGER NOT NULL REFERENCES acq.distribution_formula(id)
+                               DEFERRABLE INITIALLY DEFERRED,
+       position        INTEGER NOT NULL,
+       item_count      INTEGER NOT NULL,
+       owning_lib      INTEGER REFERENCES actor.org_unit(id)
+                               DEFERRABLE INITIALLY DEFERRED,
+       location        INTEGER REFERENCES asset.copy_location(id),
+       CONSTRAINT acqdfe_lib_once_per_formula UNIQUE( formula, position ),
+       CONSTRAINT acqdfe_must_be_somewhere
+                               CHECK( owning_lib IS NOT NULL OR location IS NOT NULL ) 
+);
+
+
 -- Functions