[open-ils-commits] r15452 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Feb 5 11:10:28 EST 2010
Author: scottmk
Date: 2010-02-05 11:10:25 -0500 (Fri, 05 Feb 2010)
New Revision: 15452
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql
trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
Log:
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
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2010-02-05 04:25:05 UTC (rev 15451)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2010-02-05 16:10:25 UTC (rev 15452)
@@ -3154,8 +3154,6 @@
<field reporter:label="Phone Number" name="phone" reporter:datatype="text"/>
<field reporter:label="OPAC Visible" name="opac_visible" reporter:datatype="bool"/>
<field reporter:label="Fiscal Calendar" name="fiscal_calendar" reporter:datatype="link"/>
- <field reporter:label="Spend Warning Percent" name="spend_warning_percent" reporter:datatype="int"/>
- <field reporter:label="Spend Limit Percent" name="spend_limit_percent" reporter:datatype="int"/>
<field reporter:label="Users" name="users" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Closed Dates" name="closed_dates" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Circulations" name="circulations" oils_persist:virtual="true" reporter:datatype="link"/>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-05 04:25:05 UTC (rev 15451)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-05 16:10:25 UTC (rev 15452)
@@ -51,7 +51,7 @@
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,
Modified: trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql 2010-02-05 04:25:05 UTC (rev 15451)
+++ trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql 2010-02-05 16:10:25 UTC (rev 15452)
@@ -340,11 +340,7 @@
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);
Modified: trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-02-05 04:25:05 UTC (rev 15451)
+++ trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2010-02-05 16:10:25 UTC (rev 15452)
@@ -1113,87 +1113,3 @@
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';
-
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql 2010-02-05 16:10:25 UTC (rev 15452)
@@ -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;
+
More information about the open-ils-commits
mailing list