From: Ben Shum Date: Tue, 28 Jul 2015 20:28:45 +0000 (-0400) Subject: LP#1198465: Stamping upgrade script for conditional negative balance X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ea55537955c4f632615f9104d53ed76f4a6a0263;p=evergreen%2Fpines.git LP#1198465: Stamping upgrade script for conditional negative balance Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index fe2ceebecc..d08026ef8a 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0920', :eg_version); -- miker/klussier +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0921', :eg_version); -- dyrcona/dbwells/remingtron/kmlussier/bshum CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0921.data.conditional_negative_balance.sql b/Open-ILS/src/sql/Pg/upgrade/0921.data.conditional_negative_balance.sql new file mode 100644 index 0000000000..8085a89768 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0921.data.conditional_negative_balance.sql @@ -0,0 +1,90 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0921', :eg_version); + +CREATE TABLE money.account_adjustment ( + billing BIGINT REFERENCES money.billing (id) ON DELETE SET NULL +) INHERITS (money.bnm_payment); +ALTER TABLE money.account_adjustment ADD PRIMARY KEY (id); +CREATE INDEX money_adjustment_id_idx ON money.account_adjustment (id); +CREATE INDEX money_account_adjustment_xact_idx ON money.account_adjustment (xact); +CREATE INDEX money_account_adjustment_bill_idx ON money.account_adjustment (billing); +CREATE INDEX money_account_adjustment_payment_ts_idx ON money.account_adjustment (payment_ts); +CREATE INDEX money_account_adjustment_accepting_usr_idx ON money.account_adjustment (accepting_usr); + +CREATE TRIGGER mat_summary_add_tgr AFTER INSERT ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_add ('account_adjustment'); +CREATE TRIGGER mat_summary_upd_tgr AFTER UPDATE ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_update ('account_adjustment'); +CREATE TRIGGER mat_summary_del_tgr BEFORE DELETE ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_del ('account_adjustment'); + +-- Insert new org. unit settings. +INSERT INTO config.org_unit_setting_type + (name, grp, datatype, label, description) +VALUES + ('bill.prohibit_negative_balance_default', + 'finance', 'bool', + oils_i18n_gettext( + 'bill.prohibit_negative_balance_default', + 'Prohibit negative balance on bills (DEFAULT)', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.prohibit_negative_balance_default', + 'Default setting to prevent negative balances (refunds) on circulation related bills', + 'coust', 'description') + ), + ('bill.prohibit_negative_balance_on_overdues', + 'finance', 'bool', + oils_i18n_gettext( + 'bill.prohibit_negative_balance_on_overdues', + 'Prohibit negative balance on bills for overdue materials', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.prohibit_negative_balance_on_overdues', + 'Prevent negative balances (refunds) on bills for overdue materials', + 'coust', 'description') + ), + ('bill.prohibit_negative_balance_on_lost', + 'finance', 'bool', + oils_i18n_gettext( + 'bill.prohibit_negative_balance_on_lost', + 'Prohibit negative balance on bills for lost materials', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.prohibit_negative_balance_on_lost', + 'Prevent negative balances (refunds) on bills for lost/long-overdue materials', + 'coust', 'description') + ), + ('bill.negative_balance_interval_default', + 'finance', 'interval', + oils_i18n_gettext( + 'bill.negative_balance_interval_default', + 'Negative Balance Interval (DEFAULT)', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.negative_balance_interval_default', + 'Amount of time after which no negative balances (refunds) are allowed on circulation bills', + 'coust', 'description') + ), + ('bill.negative_balance_interval_on_overdues', + 'finance', 'interval', + oils_i18n_gettext( + 'bill.negative_balance_interval_on_overdues', + 'Negative Balance Interval for Overdues', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.negative_balance_interval_on_overdues', + 'Amount of time after which no negative balances (refunds) are allowed on bills for overdue materials', + 'coust', 'description') + ), + ('bill.negative_balance_interval_on_lost', + 'finance', 'interval', + oils_i18n_gettext( + 'bill.negative_balance_interval_on_lost', + 'Negative Balance Interval for Lost', + 'coust', 'label'), + oils_i18n_gettext( + 'bill.negative_balance_interval_on_lost', + 'Amount of time after which no negative balances (refunds) are allowed on bills for lost/long overdue materials', + 'coust', 'description') + ); + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.conditional_negative_balance.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.conditional_negative_balance.sql deleted file mode 100644 index 0bf8ec172f..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.conditional_negative_balance.sql +++ /dev/null @@ -1,90 +0,0 @@ -BEGIN; - --- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - -CREATE TABLE money.account_adjustment ( - billing BIGINT REFERENCES money.billing (id) ON DELETE SET NULL -) INHERITS (money.bnm_payment); -ALTER TABLE money.account_adjustment ADD PRIMARY KEY (id); -CREATE INDEX money_adjustment_id_idx ON money.account_adjustment (id); -CREATE INDEX money_account_adjustment_xact_idx ON money.account_adjustment (xact); -CREATE INDEX money_account_adjustment_bill_idx ON money.account_adjustment (billing); -CREATE INDEX money_account_adjustment_payment_ts_idx ON money.account_adjustment (payment_ts); -CREATE INDEX money_account_adjustment_accepting_usr_idx ON money.account_adjustment (accepting_usr); - -CREATE TRIGGER mat_summary_add_tgr AFTER INSERT ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_add ('account_adjustment'); -CREATE TRIGGER mat_summary_upd_tgr AFTER UPDATE ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_update ('account_adjustment'); -CREATE TRIGGER mat_summary_del_tgr BEFORE DELETE ON money.account_adjustment FOR EACH ROW EXECUTE PROCEDURE money.materialized_summary_payment_del ('account_adjustment'); - --- Insert new org. unit settings. -INSERT INTO config.org_unit_setting_type - (name, grp, datatype, label, description) -VALUES - ('bill.prohibit_negative_balance_default', - 'finance', 'bool', - oils_i18n_gettext( - 'bill.prohibit_negative_balance_default', - 'Prohibit negative balance on bills (DEFAULT)', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.prohibit_negative_balance_default', - 'Default setting to prevent negative balances (refunds) on circulation related bills', - 'coust', 'description') - ), - ('bill.prohibit_negative_balance_on_overdues', - 'finance', 'bool', - oils_i18n_gettext( - 'bill.prohibit_negative_balance_on_overdues', - 'Prohibit negative balance on bills for overdue materials', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.prohibit_negative_balance_on_overdues', - 'Prevent negative balances (refunds) on bills for overdue materials', - 'coust', 'description') - ), - ('bill.prohibit_negative_balance_on_lost', - 'finance', 'bool', - oils_i18n_gettext( - 'bill.prohibit_negative_balance_on_lost', - 'Prohibit negative balance on bills for lost materials', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.prohibit_negative_balance_on_lost', - 'Prevent negative balances (refunds) on bills for lost/long-overdue materials', - 'coust', 'description') - ), - ('bill.negative_balance_interval_default', - 'finance', 'interval', - oils_i18n_gettext( - 'bill.negative_balance_interval_default', - 'Negative Balance Interval (DEFAULT)', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.negative_balance_interval_default', - 'Amount of time after which no negative balances (refunds) are allowed on circulation bills', - 'coust', 'description') - ), - ('bill.negative_balance_interval_on_overdues', - 'finance', 'interval', - oils_i18n_gettext( - 'bill.negative_balance_interval_on_overdues', - 'Negative Balance Interval for Overdues', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.negative_balance_interval_on_overdues', - 'Amount of time after which no negative balances (refunds) are allowed on bills for overdue materials', - 'coust', 'description') - ), - ('bill.negative_balance_interval_on_lost', - 'finance', 'interval', - oils_i18n_gettext( - 'bill.negative_balance_interval_on_lost', - 'Negative Balance Interval for Lost', - 'coust', 'label'), - oils_i18n_gettext( - 'bill.negative_balance_interval_on_lost', - 'Amount of time after which no negative balances (refunds) are allowed on bills for lost/long overdue materials', - 'coust', 'description') - ); - -COMMIT;