LP#1748924 Disable materialized summary updates in upgrade script
authorDan Wells <dbw2@calvin.edu>
Thu, 1 Mar 2018 18:41:06 +0000 (13:41 -0500)
committerJeff Godin <jgodin@tadl.org>
Thu, 1 Mar 2018 18:57:50 +0000 (13:57 -0500)
We are not touching billing_ts, so this trigger eats up a lot of
time for nothing.  Disable it during the upgrade process.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Jeff Godin <jgodin@tadl.org>

Open-ILS/src/sql/Pg/upgrade/XXXX.data.expand_billing_timestamps.sql

index e88b4cc..2bb7468 100644 (file)
@@ -7,6 +7,11 @@ ALTER TABLE money.billing
        ADD COLUMN period_start    TIMESTAMP WITH TIME ZONE,
        ADD COLUMN period_end  TIMESTAMP WITH TIME ZONE;
 
+--Disable materialized update trigger
+--It takes forever, and doesn't matter yet for what we are doing, as the
+--view definition is unchanged (still using billing_ts)
+ALTER TABLE money.billing DISABLE TRIGGER mat_summary_upd_tgr;
+
 --Limit to btype=1 / 'Overdue Materials'
 --Update day-granular fines first (i.e. 24 hour, 1 day, 2 day, etc., all of which are multiples of 86400 seconds), and simply remove the time portion of timestamp
 UPDATE money.billing mb
@@ -27,6 +32,9 @@ WHERE mb.xact = ac.id
 SET CONSTRAINTS ALL IMMEDIATE;
 UPDATE money.billing SET create_date = COALESCE(period_start, billing_ts);
 
+--Re-enable update trigger
+ALTER TABLE money.billing ENABLE TRIGGER mat_summary_upd_tgr;
+
 ALTER TABLE money.billing ALTER COLUMN create_date SET DEFAULT NOW();
 ALTER TABLE money.billing ALTER COLUMN create_date SET NOT NULL;