From 68a82e7eea6df75eae3966c95538047af0e98a57 Mon Sep 17 00:00:00 2001
From: Mike Rylander <mrylander@gmail.com>
Date: Mon, 10 Oct 2011 13:32:55 -0400
Subject: [PATCH] Stamped upgrade script for Grace Period Closed-Date Extension
 features

Signed-off-by: Mike Rylander <mrylander@gmail.com>
---
 Open-ILS/src/sql/Pg/002.schema.config.sql          |  2 +-
 ...xtend.sql => 0636.data.grace_period_extend.sql} | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
 rename Open-ILS/src/sql/Pg/upgrade/{XXXX.data.grace_period_extend.sql => 0636.data.grace_period_extend.sql} (64%)

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index e52f406b05..44423b0f68 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,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 ('0635', :eg_version); -- berick/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0636', :eg_version); -- miker/tsbere
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.grace_period_extend.sql b/Open-ILS/src/sql/Pg/upgrade/0636.data.grace_period_extend.sql
similarity index 64%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.grace_period_extend.sql
rename to Open-ILS/src/sql/Pg/upgrade/0636.data.grace_period_extend.sql
index 84ed345873..97757e5a86 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.grace_period_extend.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0636.data.grace_period_extend.sql
@@ -1,3 +1,24 @@
+-- Evergreen DB patch 0636.data.grace_period_extend.sql
+--
+-- OU setting turns on grace period auto extension. By default they only do so
+-- when the grace period ends on a closed date, but there are two modifiers to
+-- change that.
+-- 
+-- The first modifier causes grace periods to extend for all closed dates that
+-- they intersect. This is "grace periods are only consumed by open days."
+-- 
+-- The second modifier causes a grace period that ends just before a closed
+-- day, with or without extension having happened, to include the closed day
+-- (and any following it) as well. This is mainly so that a backdate into the
+-- closed period following the grace period will assume the "best case" of the
+-- item having been returned after hours on the last day of the closed date.
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0636', :eg_version);
+
 INSERT INTO config.org_unit_setting_type(name, grp, label, description, datatype) VALUES
 
 ( 'circ.grace.extend', 'circ',
@@ -26,3 +47,6 @@ INSERT INTO config.org_unit_setting_type(name, grp, label, description, datatype
          'If enabled and Grace Periods auto-extending is turned on grace periods will include closed dates that directly follow the last day of the grace period, to allow a backdate into the closed dates to assume "returned after hours on the last day of the grace period, and thus still within it" automatically.',
         'coust', 'description'),
     'bool', null);
+
+
+COMMIT;
-- 
2.11.0