From: Bill Erickson Date: Fri, 24 Apr 2020 14:42:42 +0000 (-0400) Subject: LP1858448 Disable inititial aged money migration X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f5992131d0da50115a1ce312d8683c4011ef13d9;p=Evergreen.git LP1858448 Disable inititial aged money migration 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 Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/sql/Pg/upgrade/1181.schema.aged-billing-payment.sql b/Open-ILS/src/sql/Pg/upgrade/1181.schema.aged-billing-payment.sql index 5fbfd69788..e1dbf18c22 100644 --- a/Open-ILS/src/sql/Pg/upgrade/1181.schema.aged-billing-payment.sql +++ b/Open-ILS/src/sql/Pg/upgrade/1181.schema.aged-billing-payment.sql @@ -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; +*/ diff --git a/Open-ILS/src/sql/Pg/upgrade/1192.schema.fix_circ_aging.sql b/Open-ILS/src/sql/Pg/upgrade/1192.schema.fix_circ_aging.sql index 8a1cf92a4a..eed4d5b267 100644 --- a/Open-ILS/src/sql/Pg/upgrade/1192.schema.fix_circ_aging.sql +++ b/Open-ILS/src/sql/Pg/upgrade/1192.schema.fix_circ_aging.sql @@ -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'; diff --git a/Open-ILS/src/sql/Pg/version-upgrade/3.3.3-3.4.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/3.3.3-3.4.0-upgrade-db.sql index 8cd090e1cc..4a88a1b4ca 100644 --- a/Open-ILS/src/sql/Pg/version-upgrade/3.3.3-3.4.0-upgrade-db.sql +++ b/Open-ILS/src/sql/Pg/version-upgrade/3.3.3-3.4.0-upgrade-db.sql @@ -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;