From 9dff0defae38eee78d6dac73cc57dd03de589b50 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 8 Aug 2011 09:07:40 -0400 Subject: [PATCH] Ign Reshelving->Available for status_changed_time This solves a complication when wanting to check status_changed_time against offline xact_time when processing offline transactions. Signed-off-by: Jason Etheridge Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/040.schema.asset.sql | 2 +- .../YYYY.schema.acp_status_date_changed.sql | 29 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index ddb116a152..4698e3f8d6 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -117,7 +117,7 @@ CREATE UNIQUE INDEX opac_visible_copies_once_per_record_idx on asset.opac_visibl CREATE OR REPLACE FUNCTION asset.acp_status_changed() RETURNS TRIGGER AS $$ BEGIN - IF NEW.status <> OLD.status THEN + IF NEW.status <> OLD.status AND NOT (NEW.status = 0 AND OLD.status = 7) THEN NEW.status_changed_time := now(); IF NEW.active_date IS NULL AND NEW.status IN (SELECT id FROM config.copy_status WHERE copy_active = true) THEN NEW.active_date := now(); diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql new file mode 100644 index 0000000000..34715d1011 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.acp_status_date_changed.sql @@ -0,0 +1,29 @@ +-- Evergreen DB patch YYYY.schema.acp_status_date_changed.sql +-- +-- Change trigger which updates copy status_changed_time to ignore the +-- Reshelving->Available status rollover +-BEGIN; + +-- FIXME: 0039.schema.acp_status_date_changed.sql defines this the first time +-- around, but along with the column itself, etc. And it gets modified with +-- 0562.schema.copy_active_date.sql. Not sure how to use the supercedes / +-- deprecate stuff for upgrade scripts, if it's even applicable when a given +-- upgrade script is doing so much. + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version); + +CREATE OR REPLACE FUNCTION asset.acp_status_changed() +RETURNS TRIGGER AS $$ +BEGIN + IF NEW.status <> OLD.status AND NOT (NEW.status = 0 AND OLD.status = 7) THEN + NEW.status_changed_time := now(); + IF NEW.active_date IS NULL AND NEW.status IN (SELECT id FROM config.copy_status WHERE copy_active = true) THEN + NEW.active_date := now(); + END IF; + END IF; + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +COMMIT; -- 2.11.0