From: Dan Wells <dbw2@calvin.edu>
Date: Thu, 1 Mar 2018 18:41:06 +0000 (-0500)
Subject: LP#1748924 Disable materialized summary updates in upgrade script
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2eb265e1e1c4a64d65c8045da82539633e45b6e8;p=evergreen%2Fjoelewis.git

LP#1748924 Disable materialized summary updates in upgrade script

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>
---

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.expand_billing_timestamps.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.expand_billing_timestamps.sql
index e88b4cc3af..2bb74689ff 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.expand_billing_timestamps.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.expand_billing_timestamps.sql
@@ -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;