Copy Location Circ Limit Sets : DB/IDL 4 circ-copy-location-limit-sets
authorBill Erickson <berick@esilibrary.com>
Mon, 16 Apr 2012 14:03:03 +0000 (10:03 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 16 Apr 2012 14:03:03 +0000 (10:03 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/sql/Pg/100.circ_matrix.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_loc_circ_limits.sql

index a1912b1..94bc7e3 100644 (file)
@@ -122,6 +122,14 @@ CREATE TABLE config.circ_limit_set_circ_mod_map (
     CONSTRAINT cm_once_per_set UNIQUE (limit_set, circ_mod)
 );
 
+-- Linkage between limit sets and copy locations
+CREATE TABLE config.circ_limit_set_copy_loc_map (
+    id          SERIAL  PRIMARY KEY,
+    limit_set   INT     NOT NULL REFERENCES config.circ_limit_set (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+    copy_loc    INT     NOT NULL REFERENCES asset.copy_location (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
+    CONSTRAINT cl_once_per_set UNIQUE (limit_set, copy_loc)
+);
+
 -- Linkage between limit sets and limit groups
 CREATE TABLE config.circ_limit_set_group_map (
     id          SERIAL  PRIMARY KEY,
index d36b11f..7bd883d 100644 (file)
@@ -1,12 +1,13 @@
 
 -- Linkage between limit sets and circ mods
---CREATE TABLE config.circ_limit_set_copy_loc_map (
-    --id          SERIAL  PRIMARY KEY,
-    --limit_set   INT     NOT NULL REFERENCES config.circ_limit_set (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
-    --copy_loc    INT     NOT NULL REFERENCES asset.copy_location (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
-    --CONSTRAINT cl_once_per_set UNIQUE (limit_set, copy_loc)
---);
-
+CREATE TABLE config.circ_limit_set_copy_loc_map (
+    id          SERIAL  PRIMARY KEY,
+    limit_set   INT     NOT NULL REFERENCES config.circ_limit_set (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+    copy_loc    INT     NOT NULL REFERENCES asset.copy_location (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
+    CONSTRAINT cl_once_per_set UNIQUE (limit_set, copy_loc)
+);
+
+-- Add support for checking config.circ_limit_set_copy_loc_map's
 CREATE OR REPLACE FUNCTION action.item_user_circ_test( circ_ou INT, match_item BIGINT, match_user INT, renewal BOOL ) 
     RETURNS SETOF action.circ_matrix_test_result AS $func$
 DECLARE
@@ -227,9 +228,3 @@ BEGIN
 END;
 $func$ LANGUAGE plpgsql;
 
-
-/* 
--- UNDO
-DROP TABLE IF EXISTS config.circ_limit_set_copy_loc_map;
-*/
-