From 88f9ec1a089c71e5fb57a62edb22789776817e2e Mon Sep 17 00:00:00 2001 From: scottmk Date: Fri, 5 Feb 2010 16:10:25 +0000 Subject: [PATCH] Undoing most of the previous commit, having been shown a Better Way... M Open-ILS/src/sql/Pg/005.schema.actors.sql M Open-ILS/src/sql/Pg/999.functions.global.sql M Open-ILS/src/sql/Pg/002.schema.config.sql A Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql M Open-ILS/examples/fm_IDL.xml git-svn-id: svn://svn.open-ils.org/ILS/trunk@15452 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 2 - Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/005.schema.actors.sql | 6 +- Open-ILS/src/sql/Pg/999.functions.global.sql | 84 ---------------------- .../0152.schema.acq.undo-spending-limits.sql | 27 +++++++ 5 files changed, 29 insertions(+), 92 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index f6fca23e8..4252dd7fd 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3154,8 +3154,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index fb1a3861f..80319adb7 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0151'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0152'); -- Scott McKellar CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 314e6a556..7508b7136 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -340,11 +340,7 @@ CREATE TABLE actor.org_unit ( email TEXT, phone TEXT, opac_visible BOOL NOT NULL DEFAULT TRUE, - fiscal_calendar INT NOT NULL DEFAULT 1, -- foreign key constraint to be added later - spend_warning_percent INT CONSTRAINT spend_warning_percent_limit - CHECK( spend_warning_percent <= 100 ), - spend_limit_percent INT CONSTRAINT spend_limit_percent_limit - CHECK( spend_limit_percent <= 100 ) + fiscal_calendar INT NOT NULL DEFAULT 1 -- foreign key constraint to be added later ); CREATE INDEX actor_org_unit_parent_ou_idx ON actor.org_unit (parent_ou); CREATE INDEX actor_org_unit_ou_type_idx ON actor.org_unit (ou_type); diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index 7a9e731c9..e13d0e5b7 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -1113,87 +1113,3 @@ CREATE TRIGGER fingerprint_tgr BEFORE INSERT OR UPDATE ON biblio.record_entry FO CREATE TRIGGER aaa_indexing_ingest_or_delete AFTER INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.indexing_ingest_or_delete (); CREATE TRIGGER bbb_simple_rec_trigger AFTER INSERT OR UPDATE ON biblio.record_entry FOR EACH ROW EXECUTE PROCEDURE reporter.simple_rec_trigger (); -CREATE OR REPLACE FUNCTION acq.default_spend_limit( org_unit_id IN INT ) -RETURNS INTEGER AS $$ -DECLARE - org INT; - key_id INT; - percent INT; - parent INT; -BEGIN - org := org_unit_id; - WHILE percent IS NULL LOOP - SELECT - id, - spend_limit_percent, - parent_ou - INTO - key_id, - percent, - parent - FROM - actor.org_unit - WHERE - id = org; - -- - IF key_id IS NULL THEN - RAISE EXCEPTION 'Org_unit id % is not valid', org_unit_id; - END IF; - -- - IF parent IS NULL THEN - EXIT; - ELSE - org := parent; - END IF; - END LOOP; - -- - IF percent IS NULL THEN - RETURN 0; -- Last-ditch default - ELSE - RETURN percent; - END IF; -END; -$$ LANGUAGE 'plpgsql'; - -CREATE OR REPLACE FUNCTION acq.default_warning_limit( org_unit_id IN INT ) -RETURNS INTEGER AS $$ -DECLARE - org INT; - key_id INT; - percent INT; - parent INT; -BEGIN - org := org_unit_id; - WHILE percent IS NULL LOOP - SELECT - id, - spend_warning_percent, - parent_ou - INTO - key_id, - percent, - parent - FROM - actor.org_unit - WHERE - id = org; - -- - IF key_id IS NULL THEN - RAISE EXCEPTION 'Org_unit id % is not valid', org_unit_id; - END IF; - -- - IF parent IS NULL THEN - EXIT; - ELSE - org := parent; - END IF; - END LOOP; - -- - IF percent IS NULL THEN - RETURN 10; -- Last-ditch default - ELSE - RETURN percent; - END IF; -END; -$$ LANGUAGE 'plpgsql'; - diff --git a/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql b/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql new file mode 100644 index 000000000..ea14b6caa --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql @@ -0,0 +1,27 @@ +BEGIN; + +-- Undoing some ill-considered changes... + +INSERT INTO config.upgrade_log (version) VALUES ('0152'); -- Scott McKellar + +ALTER TABLE actor.org_unit + DROP COLUMN spend_warning_percent; + +ALTER TABLE actor.org_unit + DROP COLUMN spend_limit_percent; + +DROP FUNCTION acq.default_spend_limit( INT ); + +DROP FUNCTION acq.default_warning_limit( INT ); + +COMMIT; + +-- If there is no auditor schema, the following ALTERs +-- will fail, and that's okay. + +ALTER TABLE auditor.actor_org_unit_history + DROP COLUMN spend_warning_percent; + +ALTER TABLE auditor.actor_org_unit_history + DROP COLUMN spend_limit_percent; + -- 2.11.0