From bee7ce4ec826ae74a8d7c297c23525b37b5d2c96 Mon Sep 17 00:00:00 2001 From: gmc Date: Mon, 1 Nov 2010 15:39:39 +0000 Subject: [PATCH] let libraries allow funds to be overcommitted The check constraints on the balance warning and stop limits were too strict - a library can validly choose to permit a fund to have a commitment greater than 100% of its allocation Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/trunk@18543 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql | 8 ++------ Open-ILS/src/sql/Pg/200.schema.acq.sql | 6 ++---- .../Pg/upgrade/0450.schema.drop-balance-check-constraints.sql | 9 +++++++++ 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0450.schema.drop-balance-check-constraints.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 84eaef0f0d..b15c550678 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0449'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0450'); -- gmc CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql b/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql index f9876c781e..ed35d024ed 100644 --- a/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql +++ b/Open-ILS/src/sql/Pg/1.6.1-2.0-upgrade-db.sql @@ -9404,14 +9404,10 @@ ALTER TABLE acq.fund ADD COLUMN active BOOL NOT NULL DEFAULT TRUE; ALTER TABLE acq.fund - ADD COLUMN balance_warning_percent INT - CONSTRAINT balance_warning_percent_limit - CHECK( balance_warning_percent <= 100 ); + ADD COLUMN balance_warning_percent INT; ALTER TABLE acq.fund - ADD COLUMN balance_stop_percent INT - CONSTRAINT balance_stop_percent_limit - CHECK( balance_stop_percent <= 100 ); + ADD COLUMN balance_stop_percent INT; CREATE VIEW acq.ordered_funding_source_credit AS SELECT diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 0db32d72b7..bb08fbef57 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -225,10 +225,8 @@ CREATE TABLE acq.fund ( rollover BOOL NOT NULL DEFAULT FALSE, propagate BOOL NOT NULL DEFAULT TRUE, active BOOL NOT NULL DEFAULT TRUE, - balance_warning_percent INT CONSTRAINT balance_warning_percent_limit - CHECK( balance_warning_percent <= 100 ), - balance_stop_percent INT CONSTRAINT balance_stop_percent_limit - CHECK( balance_stop_percent <= 100 ), + balance_warning_percent INT, + balance_stop_percent INT, CONSTRAINT name_once_per_org_year UNIQUE (org,name,year), CONSTRAINT code_once_per_org_year UNIQUE (org, code, year), CONSTRAINT acq_fund_rollover_implies_propagate CHECK ( propagate OR NOT rollover ) diff --git a/Open-ILS/src/sql/Pg/upgrade/0450.schema.drop-balance-check-constraints.sql b/Open-ILS/src/sql/Pg/upgrade/0450.schema.drop-balance-check-constraints.sql new file mode 100644 index 0000000000..483231cdab --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0450.schema.drop-balance-check-constraints.sql @@ -0,0 +1,9 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0450'); -- gmc + +-- libraries can choose to overcommit funds +ALTER TABLE acq.fund DROP CONSTRAINT balance_warning_percent_limit; +ALTER TABLE acq.fund DROP CONSTRAINT balance_stop_percent_limit; + +COMMIT; -- 2.11.0