LP#1599634: change ID column in view to BIGINT
authorGalen Charlton <gmc@esilibrary.com>
Thu, 11 Aug 2016 14:41:29 +0000 (10:41 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 11 Aug 2016 14:41:29 +0000 (10:41 -0400)
This patches changes the ID column to just pass through
the ID from the source tables, promoted to BIGINT in
some cases.  This has the effect of:

- removing a redundancy, as circ_type already specifies the source table
- making it easier to join this view against the circulation tables when
  writing SQL queries

This patch also renames the schema upgrade script to better
match conventions.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.LP1599634_Circulation_report_source_to_include_in-house_and_non_cat_circ.sql [deleted file]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_circulation_combined_types_view.sql [new file with mode: 0644]

index 4a3f25d..148ab9b 100644 (file)
@@ -4212,7 +4212,7 @@ SELECT  usr,
                <fields>
                        <field reporter:label="Circulating Library" name="circ_lib" reporter:datatype="org_unit"/>
                        <field reporter:label="Circulating Staff" name="circ_staff" reporter:datatype="link"/>
-                       <field reporter:label="Circ ID" name="id" reporter:datatype="text" />
+                       <field reporter:label="Circ ID" name="id" reporter:datatype="int" />
                        <field reporter:label="Checkout Date/Time" name="xact_start" reporter:datatype="timestamp" />
                        <field reporter:label="Create Date/Time" name="create_time" reporter:datatype="timestamp" />
                        <field reporter:label="Circulation Type" name="circ_type" reporter:datatype="text"/>
index 9e5a63d..f42dcc1 100644 (file)
@@ -1403,7 +1403,7 @@ CREATE TRIGGER maintain_usr_circ_history_tgr
     FOR EACH ROW EXECUTE PROCEDURE action.maintain_usr_circ_history();
 
 CREATE OR REPLACE VIEW action.all_circulation_combined_types AS 
- SELECT 'regularcirc'::text || acirc.id AS id,
+ SELECT acirc.id AS id,
     acirc.xact_start,
     acirc.circ_lib,
     acirc.circ_staff,
@@ -1414,7 +1414,7 @@ CREATE OR REPLACE VIEW action.all_circulation_combined_types AS
     asset.copy ac_acirc
   WHERE acirc.target_copy = ac_acirc.id
 UNION ALL
- SELECT 'noncatcirc'::text || ancc.id AS id,
+ SELECT ancc.id::BIGINT AS id,
     ancc.circ_time AS xact_start,
     ancc.circ_lib,
     ancc.staff AS circ_staff,
@@ -1425,7 +1425,7 @@ UNION ALL
     config.non_cataloged_type cnct_ancc
   WHERE ancc.item_type = cnct_ancc.id
 UNION ALL
- SELECT 'inhouseuse'::text || aihu.id AS id,
+ SELECT aihu.id::BIGINT AS id,
     aihu.use_time AS xact_start,
     aihu.org_unit AS circ_lib,
     aihu.staff AS circ_staff,
@@ -1436,7 +1436,7 @@ UNION ALL
     asset.copy ac_aihu
   WHERE aihu.item = ac_aihu.id
 UNION ALL
- SELECT 'noncatinhouseuse'::text || ancihu.id AS id,
+ SELECT ancihu.id::BIGINT AS id,
     ancihu.use_time AS xact_start,
     ancihu.org_unit AS circ_lib,
     ancihu.staff AS circ_staff,
@@ -1447,7 +1447,7 @@ UNION ALL
     config.non_cataloged_type cnct_ancihu
   WHERE ancihu.item_type = cnct_ancihu.id
 UNION ALL
- SELECT 'agedcirc'::text || aacirc.id::text AS id,
+ SELECT aacirc.id AS id,
     aacirc.xact_start,
     aacirc.circ_lib,
     aacirc.circ_staff,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1599634_Circulation_report_source_to_include_in-house_and_non_cat_circ.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1599634_Circulation_report_source_to_include_in-house_and_non_cat_circ.sql
deleted file mode 100644 (file)
index 76061cc..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-BEGIN;
-
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE VIEW action.all_circulation_combined_types AS 
- SELECT 'regularcirc'::text || acirc.id AS id,
-    acirc.xact_start,
-    acirc.circ_lib,
-    acirc.circ_staff,
-    acirc.create_time,
-    ac_acirc.circ_modifier AS item_type,
-    'regular_circ'::text AS circ_type
-   FROM action.circulation acirc,
-    asset.copy ac_acirc
-  WHERE acirc.target_copy = ac_acirc.id
-UNION ALL
- SELECT 'noncatcirc'::text || ancc.id AS id,
-    ancc.circ_time AS xact_start,
-    ancc.circ_lib,
-    ancc.staff AS circ_staff,
-    ancc.circ_time AS create_time,
-    cnct_ancc.name AS item_type,
-    'non-cat_circ'::text AS circ_type
-   FROM action.non_cataloged_circulation ancc,
-    config.non_cataloged_type cnct_ancc
-  WHERE ancc.item_type = cnct_ancc.id
-UNION ALL
- SELECT 'inhouseuse'::text || aihu.id AS id,
-    aihu.use_time AS xact_start,
-    aihu.org_unit AS circ_lib,
-    aihu.staff AS circ_staff,
-    aihu.use_time AS create_time,
-    ac_aihu.circ_modifier AS item_type,
-    'in-house_use'::text AS circ_type
-   FROM action.in_house_use aihu,
-    asset.copy ac_aihu
-  WHERE aihu.item = ac_aihu.id
-UNION ALL
- SELECT 'noncatinhouseuse'::text || ancihu.id AS id,
-    ancihu.use_time AS xact_start,
-    ancihu.org_unit AS circ_lib,
-    ancihu.staff AS circ_staff,
-    ancihu.use_time AS create_time,
-    cnct_ancihu.name AS item_type,
-    'non-cat_circ'::text AS circ_type
-   FROM action.non_cat_in_house_use ancihu,
-    config.non_cataloged_type cnct_ancihu
-  WHERE ancihu.item_type = cnct_ancihu.id
-UNION ALL
- SELECT 'agedcirc'::text || aacirc.id::text AS id,
-    aacirc.xact_start,
-    aacirc.circ_lib,
-    aacirc.circ_staff,
-    aacirc.create_time,
-    ac_aacirc.circ_modifier AS item_type,
-    'aged_circ'::text AS circ_type
-   FROM action.aged_circulation aacirc,
-    asset.copy ac_aacirc
-  WHERE aacirc.target_copy = ac_aacirc.id;
-
-COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_circulation_combined_types_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.all_circulation_combined_types_view.sql
new file mode 100644 (file)
index 0000000..e76686b
--- /dev/null
@@ -0,0 +1,61 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW action.all_circulation_combined_types AS 
+ SELECT acirc.id AS id,
+    acirc.xact_start,
+    acirc.circ_lib,
+    acirc.circ_staff,
+    acirc.create_time,
+    ac_acirc.circ_modifier AS item_type,
+    'regular_circ'::text AS circ_type
+   FROM action.circulation acirc,
+    asset.copy ac_acirc
+  WHERE acirc.target_copy = ac_acirc.id
+UNION ALL
+ SELECT ancc.id::BIGINT AS id,
+    ancc.circ_time AS xact_start,
+    ancc.circ_lib,
+    ancc.staff AS circ_staff,
+    ancc.circ_time AS create_time,
+    cnct_ancc.name AS item_type,
+    'non-cat_circ'::text AS circ_type
+   FROM action.non_cataloged_circulation ancc,
+    config.non_cataloged_type cnct_ancc
+  WHERE ancc.item_type = cnct_ancc.id
+UNION ALL
+ SELECT aihu.id::BIGINT AS id,
+    aihu.use_time AS xact_start,
+    aihu.org_unit AS circ_lib,
+    aihu.staff AS circ_staff,
+    aihu.use_time AS create_time,
+    ac_aihu.circ_modifier AS item_type,
+    'in-house_use'::text AS circ_type
+   FROM action.in_house_use aihu,
+    asset.copy ac_aihu
+  WHERE aihu.item = ac_aihu.id
+UNION ALL
+ SELECT ancihu.id::BIGINT AS id,
+    ancihu.use_time AS xact_start,
+    ancihu.org_unit AS circ_lib,
+    ancihu.staff AS circ_staff,
+    ancihu.use_time AS create_time,
+    cnct_ancihu.name AS item_type,
+    'non-cat_circ'::text AS circ_type
+   FROM action.non_cat_in_house_use ancihu,
+    config.non_cataloged_type cnct_ancihu
+  WHERE ancihu.item_type = cnct_ancihu.id
+UNION ALL
+ SELECT aacirc.id AS id,
+    aacirc.xact_start,
+    aacirc.circ_lib,
+    aacirc.circ_staff,
+    aacirc.create_time,
+    ac_aacirc.circ_modifier AS item_type,
+    'aged_circ'::text AS circ_type
+   FROM action.aged_circulation aacirc,
+    asset.copy ac_aacirc
+  WHERE aacirc.target_copy = ac_aacirc.id;
+
+COMMIT;