adding fk constraint to hold_type on action.hold_request and reporter class
authorRogan Hamby <rogan.hamby@gmail.com>
Tue, 16 Apr 2019 16:49:07 +0000 (12:49 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 1 Aug 2019 10:54:12 +0000 (06:54 -0400)
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.action_hold_request_fkey_to_hold_type.sql [new file with mode: 0644]

index 7270ee3..c8db25c 100644 (file)
@@ -6356,6 +6356,7 @@ SELECT  usr,
                        <link field="current_shelf_lib" reltype="has_a" key="id" map="" class="aou"/>
                        <link field="sms_carrier" reltype="has_a" key="id" map="" class="csc"/>
                        <link field="acq_request" reltype="has_a" key="id" map="" class="aur"/>
+                       <link field="hold_type" reltype="has_a" key="hold_type" map="" class="cht"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
@@ -12813,6 +12814,14 @@ SELECT  usr,
                </links>
        </class>
 
+       <class id="cht" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::hold_type" oils_persist:tablename="config.hold_type" reporter:label="Hold Type" oils_persist:readonly="true">
+       <fields oils_persist:primary="id" oils_persist:sequence="config.hold_type_id_seq">
+               <field name="id" reporter:selector="name" reporter:datatype="id"/>
+               <field name="description"  reporter:datatype="text" oils_persist:i18n="true"/>
+               <field name="hold_type"  reporter:datatype="text" oils_persist:i18n="true"/>
+       </fields>
+       </class>
+
        <!-- ********************************************************************************************************************* -->
 </IDL>
 
index b516ac6..d70e59d 100644 (file)
@@ -1318,4 +1318,21 @@ CREATE TABLE config.copy_tag_type (
 CREATE INDEX config_copy_tag_type_owner_idx
     ON config.copy_tag_type (owner);
 
+CREATE TABLE config.hold_type (
+    id          SERIAL,
+    hold_type   TEXT UNIQUE,
+    description TEXT
+);
+
+INSERT INTO config.hold_type (hold_type,description) VALUES
+    ('C','Copy Hold'),
+    ('V','Volume Hold'),
+    ('T','Title Hold'),
+    ('M','Metarecord Hold'),
+    ('R','Recall Hold'),
+    ('F','Force Hold'),
+    ('I','Issuance Hold'),
+    ('P','Part Hold')
+;
+
 COMMIT;
index b2d2e18..900c1b3 100644 (file)
@@ -442,7 +442,7 @@ CREATE TABLE action.hold_request (
        selection_ou            INT                             NOT NULL,
        selection_depth         INT                             NOT NULL DEFAULT 0,
        pickup_lib              INT                             NOT NULL REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED,
-       hold_type               TEXT                            NOT NULL, -- CHECK (hold_type IN ('M','T','V','C')),  -- XXX constraint too constraining...
+       hold_type               TEXT                            REFERENCES config.hold_type (hold_type) DEFERRABLE INITIALLY DEFERRED,
        holdable_formats        TEXT,
        phone_notify            TEXT,
        email_notify            BOOL                            NOT NULL DEFAULT FALSE,
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.action_hold_request_fkey_to_hold_type.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.action_hold_request_fkey_to_hold_type.sql
new file mode 100644 (file)
index 0000000..8362f62
--- /dev/null
@@ -0,0 +1,19 @@
+CREATE TABLE config.hold_type (
+    id          SERIAL,
+    hold_type   TEXT UNIQUE,
+    description TEXT
+);
+
+INSERT INTO config.hold_type (hold_type,description) VALUES
+    ('C','Copy Hold'),
+    ('V','Volume Hold'),
+    ('T','Title Hold'),
+    ('M','Metarecord Hold'),
+    ('R','Recall Hold'),
+    ('F','Force Hold'),
+    ('I','Issuance Hold'),
+    ('P','Part Hold')
+;
+
+ALTER TABLE action.hold_request ADD CONSTRAINT hold_request_hold_type_fkey FOREIGN KEY (hold_type) REFERENCES config.hold_type(hold_type) DEFERRABLE INITIALLY DEFERRED;
+