[open-ils-commits] r20475 - in trunk/Open-ILS/src/sql/Pg: . upgrade (gmc)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri May 13 16:58:05 EDT 2011
Author: gmc
Date: 2011-05-13 16:57:59 -0400 (Fri, 13 May 2011)
New Revision: 20475
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0533.schema.fix_age_circ.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
add missing update script for change to circ age stored procedure
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-05-13 17:31:18 UTC (rev 20474)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2011-05-13 20:57:59 UTC (rev 20475)
@@ -86,7 +86,7 @@
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 ('0532', :eg_version); -- gmc
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0533', :eg_version); -- gmc
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0533.schema.fix_age_circ.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0533.schema.fix_age_circ.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0533.schema.fix_age_circ.sql 2011-05-13 20:57:59 UTC (rev 20475)
@@ -0,0 +1,44 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0533'); -- gmc
+
+CREATE OR REPLACE FUNCTION action.age_circ_on_delete () RETURNS TRIGGER AS $$
+DECLARE
+found char := 'N';
+BEGIN
+
+ -- If there are any renewals for this circulation, don't archive or delete
+ -- it yet. We'll do so later, when we archive and delete the renewals.
+
+ SELECT 'Y' INTO found
+ FROM action.circulation
+ WHERE parent_circ = OLD.id
+ LIMIT 1;
+
+ IF found = 'Y' THEN
+ RETURN NULL; -- don't delete
+ END IF;
+
+ -- Archive a copy of the old row to action.aged_circulation
+
+ INSERT INTO action.aged_circulation
+ (id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
+ copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
+ circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, grace_period, due_date,
+ stop_fines_time, checkin_time, create_time, duration, fine_interval, recurring_fine,
+ max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recurring_fine_rule,
+ max_fine_rule, stop_fines, workstation, checkin_workstation, checkin_scan_time, parent_circ)
+ SELECT
+ id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
+ copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
+ circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, grace_period, due_date,
+ stop_fines_time, checkin_time, create_time, duration, fine_interval, recurring_fine,
+ max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recurring_fine_rule,
+ max_fine_rule, stop_fines, workstation, checkin_workstation, checkin_scan_time, parent_circ
+ FROM action.all_circulation WHERE id = OLD.id;
+
+ RETURN OLD;
+END;
+$$ LANGUAGE 'plpgsql';
+
+COMMIT;
More information about the open-ils-commits
mailing list