Sidestep dependency created by conifer.last_use view
authorDan Scott <dan@coffeecode.net>
Thu, 21 Nov 2019 21:20:02 +0000 (16:20 -0500)
committerDan Scott <dan@coffeecode.net>
Fri, 3 Jan 2020 19:31:28 +0000 (14:31 -0500)
Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/src/sql/Pg/version-upgrade/3.1.5-3.2.0-upgrade-db.sql

index 8a9940b..79ad511 100644 (file)
@@ -2217,6 +2217,8 @@ $$
     ( currval('action_trigger.event_definition_id_seq'), 'circ_lib' );
 
 
+-- Custom view depends on this
+DROP VIEW conifer.last_use;
 DROP VIEW action.all_circulation;
 CREATE OR REPLACE VIEW action.all_circulation AS
     SELECT  id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
@@ -2410,7 +2412,16 @@ BEGIN
 END;
 $$ LANGUAGE 'plpgsql';
 
-
+-- Recreate conifer view
+CREATE VIEW conifer.last_use AS
+ SELECT ac.id,
+    COALESCE(max(actac.xact_start), ac.create_date) AS last_circ_or_create,
+    max(actac.xact_start) AS last_circ,
+    max(aih.use_time) AS last_use
+   FROM asset.copy ac
+     LEFT JOIN action.all_circulation actac ON ac.id = actac.target_copy
+     LEFT JOIN action.in_house_use aih ON ac.id = aih.item
+  GROUP BY ac.id;
 
 SELECT evergreen.upgrade_deps_block_check('1124', :eg_version);