From d94a9edc38d8894bdc163936b4a824bfcfa2c0c7 Mon Sep 17 00:00:00 2001
From: scottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 24 May 2010 18:52:02 +0000
Subject: [PATCH] Split old org unit setting type
 circ.hold_estimate_wait_interval into two:

	circ.holds.default_estimated_wait_interval
	circ.holds.min_estimated_wait_interval

...with corresponding tweaks to label and description.

Also: change datatype from 'integer' to 'interval'.

For any existing rows in actor.org_unit_setting, pointing to the old
setting type: update them to point to circ.holds.default_estimated_wait_interval.

(Due to a foreign key constraint, the latter update has to happen in the same
transaction as the rename of the old row.)

M    Open-ILS/src/sql/Pg/002.schema.config.sql
A    Open-ILS/src/sql/Pg/upgrade/0274.data.org-setting-type-est-wait.sql
M    Open-ILS/src/sql/Pg/950.data.seed-values.sql


git-svn-id: svn://svn.open-ils.org/ILS/trunk@16489 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/sql/Pg/002.schema.config.sql          |  2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       | 13 +++++++---
 .../0274.data.org-setting-type-est-wait.sql        | 29 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 5 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0274.data.org-setting-type-est-wait.sql

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 043df4457c..10dfe7b99e 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0273'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0274'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 0758192257..12a3f57e5f 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -1716,10 +1716,15 @@ INSERT into config.org_unit_setting_type
   'Amount of time to wait before changing an item from "reshelving" status to "available".  Examples "1 day", "6 hours"',
   'interval' ),
 
-( 'circ.hold_estimate_wait_interval',
-  'Holds: Estimated Wait (Days)',
-  'When predicting the amount of time a patron will be waiting for a hold to be fulfilled, this is the default/average number of days to assume an item will be checked out.',
-  'integer' ),
+( 'circ.holds.default_estimated_wait_interval',
+  'Holds: Default Estimated Wait',
+  'When predicting the amount of time a patron will be waiting for a hold to be fulfilled, this is the default estimated length of time to assume an item will be checked out.',
+  'interval' ),
+
+( 'circ.holds.min_estimated_wait_interval',
+  'Holds: Minimum Estimated Wait',
+  'When predicting the amount of time a patron will be waiting for a hold to be fulfilled, this is the minimum estimated length of time to assume an item will be checked out.',
+  'interval' ),
 
 ( 'circ.selfcheck.patron_login_timeout',
   'Selfcheck: Patron Login Timeout (in seconds)',
diff --git a/Open-ILS/src/sql/Pg/upgrade/0274.data.org-setting-type-est-wait.sql b/Open-ILS/src/sql/Pg/upgrade/0274.data.org-setting-type-est-wait.sql
new file mode 100644
index 0000000000..f1c02adae7
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0274.data.org-setting-type-est-wait.sql
@@ -0,0 +1,29 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0274'); -- Scott McKellar
+
+UPDATE config.org_unit_setting_type SET
+	name = 'circ.holds.default_estimated_wait_interval',
+	label = 'Holds: Default Estimated Wait',
+	description = 'When predicting the amount of time a patron will be waiting for a hold to be fulfilled, this is the default estimated length of time to assume an item will be checked out.',
+	datatype = 'interval'
+WHERE name = 'circ.hold_estimate_wait_interval';
+
+UPDATE actor.org_unit_setting SET
+	name = 'circ.holds.default_estimated_wait_interval',
+	value = value || ' days'
+WHERE name = 'circ.hold_estimate_wait_interval';
+
+INSERT INTO config.org_unit_setting_type (
+	name,
+	label,
+	description,
+	datatype
+) VALUES (
+	'circ.holds.min_estimated_wait_interval',
+	'Holds: Minimum Estimated Wait',
+	'When predicting the amount of time a patron will be waiting for a hold to be fulfilled, this is the minimum estimated length of time to assume an item will be checked out.',
+	'interval'
+);
+
+COMMIT;
-- 
2.11.0