Undoing most of the previous commit, having been shown
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Feb 2010 16:10:25 +0000 (16:10 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 5 Feb 2010 16:10:25 +0000 (16:10 +0000)
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
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/999.functions.global.sql
Open-ILS/src/sql/Pg/upgrade/0152.schema.acq.undo-spending-limits.sql [new file with mode: 0644]

index f6fca23..4252dd7 100644 (file)
@@ -3154,8 +3154,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <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"/>
index fb1a386..80319ad 100644 (file)
@@ -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,
index 314e6a5..7508b71 100644 (file)
@@ -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);
index 7a9e731..e13d0e5 100644 (file)
@@ -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 (file)
index 0000000..ea14b6c
--- /dev/null
@@ -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;
+