LP1858448 Disable inititial aged money migration
authorBill Erickson <berickxx@gmail.com>
Fri, 24 Apr 2020 14:42:42 +0000 (10:42 -0400)
committerJason Stephenson <jason@sigio.com>
Tue, 28 Apr 2020 18:29:35 +0000 (14:29 -0400)
Modify the existing SQL upgrade scripts to prevent the automatic
migration of billings/payments to the new aged money tables.  This is
done to prevent data loss for sites which have not yet upgraded to the
affected versions.

The schema changes are kept so both pre- and post-upgrade sites can
follow the same schema update path.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jason Stephenson <jason@sigio.com>

Open-ILS/src/sql/Pg/upgrade/1181.schema.aged-billing-payment.sql
Open-ILS/src/sql/Pg/upgrade/1192.schema.fix_circ_aging.sql
Open-ILS/src/sql/Pg/version-upgrade/3.3.3-3.4.0-upgrade-db.sql

index 5fbfd69..e1dbf18 100644 (file)
@@ -10,6 +10,9 @@ ALTER TABLE money.aged_payment ADD COLUMN payment_type TEXT NOT NULL;
 
 CREATE TABLE money.aged_billing (LIKE money.billing INCLUDING INDEXES);
 
+
+/* LP 1858448 : Disable initial aged money migration
+
 INSERT INTO money.aged_payment 
     SELECT  mp.* FROM money.payment_view mp
     JOIN action.aged_circulation circ ON (circ.id = mp.xact);
@@ -17,6 +20,7 @@ INSERT INTO money.aged_payment
 INSERT INTO money.aged_billing
     SELECT mb.* FROM money.billing mb
     JOIN action.aged_circulation circ ON (circ.id = mb.xact);
+*/
 
 CREATE OR REPLACE VIEW money.all_payments AS
     SELECT * FROM money.payment_view 
@@ -65,6 +69,8 @@ BEGIN
 
     -- Migrate billings and payments to aged tables
 
+
+/* LP 1858448 : Disable initial aged money migration
     INSERT INTO money.aged_billing
         SELECT * FROM money.billing WHERE xact = OLD.id;
 
@@ -73,11 +79,15 @@ BEGIN
 
     DELETE FROM money.payment WHERE xact = OLD.id;
     DELETE FROM money.billing WHERE xact = OLD.id;
+*/
 
     RETURN OLD;
 END;
 $$ LANGUAGE 'plpgsql';
 
+
+/* LP 1858448 : Disable initial aged money migration
+
 -- NOTE you could COMMIT here then start a new TRANSACTION if desired.
 
 \qecho Deleting aged payments and billings from active payment/billing
@@ -128,8 +138,12 @@ ALTER TABLE money.account_adjustment
     ADD CONSTRAINT account_adjustment_billing_fkey 
     FOREIGN KEY (billing) REFERENCES money.billing (id);
 
+*/
+
 COMMIT;
 
 -- Good to run after truncating -- OK to run after COMMIT.
+/* LP 1858448 : Disable initial aged money migration
 ANALYZE money.billing;
+*/
 
index 8a1cf92..eed4d5b 100644 (file)
@@ -41,6 +41,8 @@ BEGIN
 
     -- Migrate billings and payments to aged tables
 
+
+/* LP 1858448 : Disable initial aged money migration
     INSERT INTO money.aged_billing
         SELECT * FROM money.billing WHERE xact = OLD.id;
 
@@ -50,6 +52,8 @@ BEGIN
     DELETE FROM money.payment WHERE xact = OLD.id;
     DELETE FROM money.billing WHERE xact = OLD.id;
 
+*/
+
     RETURN OLD;
 END;
 $$ LANGUAGE 'plpgsql';
index 8cd090e..4a88a1b 100644 (file)
@@ -522,6 +522,9 @@ ALTER TABLE money.aged_payment ADD COLUMN payment_type TEXT NOT NULL;
 
 CREATE TABLE money.aged_billing (LIKE money.billing INCLUDING INDEXES);
 
+
+/* LP 1858448 : Disable initial aged money migration
+
 INSERT INTO money.aged_payment 
     SELECT  mp.* FROM money.payment_view mp
     JOIN action.aged_circulation circ ON (circ.id = mp.xact);
@@ -530,6 +533,8 @@ INSERT INTO money.aged_billing
     SELECT mb.* FROM money.billing mb
     JOIN action.aged_circulation circ ON (circ.id = mb.xact);
 
+*/
+
 CREATE OR REPLACE VIEW money.all_payments AS
     SELECT * FROM money.payment_view 
     UNION ALL
@@ -577,6 +582,7 @@ BEGIN
 
     -- Migrate billings and payments to aged tables
 
+/* LP 1858448 : Disable initial aged money migration
     INSERT INTO money.aged_billing
         SELECT * FROM money.billing WHERE xact = OLD.id;
 
@@ -585,11 +591,15 @@ BEGIN
 
     DELETE FROM money.payment WHERE xact = OLD.id;
     DELETE FROM money.billing WHERE xact = OLD.id;
+*/
 
     RETURN OLD;
 END;
 $$ LANGUAGE 'plpgsql';
 
+
+/* LP 1858448 : Disable initial aged money migration
+
 -- NOTE you could COMMIT here then start a new TRANSACTION if desired.
 
 \qecho Deleting aged payments and billings from active payment/billing
@@ -644,6 +654,8 @@ ALTER TABLE money.account_adjustment
 -- Good to run after truncating -- OK to run after COMMIT.
 ANALYZE money.billing;
 
+*/
+
 
 SELECT evergreen.upgrade_deps_block_check('1182', :eg_version);
 
@@ -797,6 +809,7 @@ BEGIN
 
     -- Migrate billings and payments to aged tables
 
+/* LP 1858448 : Disable initial aged money migration
     INSERT INTO money.aged_billing
         SELECT * FROM money.billing WHERE xact = OLD.id;
 
@@ -805,6 +818,7 @@ BEGIN
 
     DELETE FROM money.payment WHERE xact = OLD.id;
     DELETE FROM money.billing WHERE xact = OLD.id;
+*/
 
     RETURN OLD;
 END;