Stamped upgrades for LP#825303
authorMike Rylander <mrylander@gmail.com>
Tue, 16 Aug 2011 13:00:43 +0000 (09:00 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 16 Aug 2011 13:00:43 +0000 (09:00 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0600.schema.fix_cat_default_class_lookup.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/0601.schema.fix_aous_lookup.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.fix_aous_lookup.sql [deleted file]
Open-ILS/src/sql/Pg/upgrade/XXXX.fix_cat_default_class_lookup.sql [deleted file]

index 896eb6b..4261943 100644 (file)
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0599', :eg_version); -- miker/gmc
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0601', :eg_version); -- miker/gmc
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0600.schema.fix_cat_default_class_lookup.sql b/Open-ILS/src/sql/Pg/upgrade/0600.schema.fix_cat_default_class_lookup.sql
new file mode 100644 (file)
index 0000000..418a78f
--- /dev/null
@@ -0,0 +1,38 @@
+-- Evergreen DB patch XXXX.fix_cat_default_class_lookup.sql
+--
+-- Fix LP#825303 by allowing for ancestor OUs to be checked
+-- when retrieving the default classification scheme.
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0600', :eg_version);
+
+CREATE OR REPLACE FUNCTION asset.label_normalizer() RETURNS TRIGGER AS $func$
+DECLARE
+    sortkey        TEXT := '';
+BEGIN
+    sortkey := NEW.label_sortkey;
+
+    IF NEW.label_class IS NULL THEN
+            NEW.label_class := COALESCE(
+            (
+                SELECT substring(value from E'\\d+')::integer
+                FROM actor.org_unit_ancestor_setting('cat.default_classification_scheme', NEW.owning_lib)
+            ), 1
+        );
+    END IF;
+
+    EXECUTE 'SELECT ' || acnc.normalizer || '(' || 
+       quote_literal( NEW.label ) || ')'
+       FROM asset.call_number_class acnc
+       WHERE acnc.id = NEW.label_class
+       INTO sortkey;
+    NEW.label_sortkey = sortkey;
+    RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0601.schema.fix_aous_lookup.sql b/Open-ILS/src/sql/Pg/upgrade/0601.schema.fix_aous_lookup.sql
new file mode 100644 (file)
index 0000000..3ca2c3b
--- /dev/null
@@ -0,0 +1,34 @@
+-- Evergreen DB patch XXXX.fix_aous_lookup.sql
+--
+-- Correct actor.org_unit_ancestor_setting so that it returns
+-- at most one setting value, rather than the entire set
+-- of values defined for the OU and its ancestors.
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0601', :eg_version);
+
+-- FIXME: add/check SQL statements to perform the upgrade
+CREATE OR REPLACE FUNCTION actor.org_unit_ancestor_setting( setting_name TEXT, org_id INT ) RETURNS SETOF actor.org_unit_setting AS $$
+DECLARE
+    setting RECORD;
+    cur_org INT;
+BEGIN
+    cur_org := org_id;
+    LOOP
+        SELECT INTO setting * FROM actor.org_unit_setting WHERE org_unit = cur_org AND name = setting_name;
+        IF FOUND THEN
+            RETURN NEXT setting;
+            EXIT;
+        END IF;
+        SELECT INTO cur_org parent_ou FROM actor.org_unit WHERE id = cur_org;
+        EXIT WHEN cur_org IS NULL;
+    END LOOP;
+    RETURN;
+END;
+$$ LANGUAGE plpgsql STABLE ROWS 1;
+
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_aous_lookup.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_aous_lookup.sql
deleted file mode 100644 (file)
index dc937be..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
--- Evergreen DB patch XXXX.fix_aous_lookup.sql
---
--- Correct actor.org_unit_ancestor_setting so that it returns
--- at most one setting value, rather than the entire set
--- of values defined for the OU and its ancestors.
---
-BEGIN;
-
-
--- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
--- FIXME: add/check SQL statements to perform the upgrade
-CREATE OR REPLACE FUNCTION actor.org_unit_ancestor_setting( setting_name TEXT, org_id INT ) RETURNS SETOF actor.org_unit_setting AS $$
-DECLARE
-    setting RECORD;
-    cur_org INT;
-BEGIN
-    cur_org := org_id;
-    LOOP
-        SELECT INTO setting * FROM actor.org_unit_setting WHERE org_unit = cur_org AND name = setting_name;
-        IF FOUND THEN
-            RETURN NEXT setting;
-            EXIT;
-        END IF;
-        SELECT INTO cur_org parent_ou FROM actor.org_unit WHERE id = cur_org;
-        EXIT WHEN cur_org IS NULL;
-    END LOOP;
-    RETURN;
-END;
-$$ LANGUAGE plpgsql STABLE ROWS 1;
-
-
-COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_cat_default_class_lookup.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.fix_cat_default_class_lookup.sql
deleted file mode 100644 (file)
index 5f52d89..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
--- Evergreen DB patch XXXX.fix_cat_default_class_lookup.sql
---
--- Fix LP#825303 by allowing for ancestor OUs to be checked
--- when retrieving the default classification scheme.
---
-BEGIN;
-
-
--- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION asset.label_normalizer() RETURNS TRIGGER AS $func$
-DECLARE
-    sortkey        TEXT := '';
-BEGIN
-    sortkey := NEW.label_sortkey;
-
-    IF NEW.label_class IS NULL THEN
-            NEW.label_class := COALESCE(
-            (
-                SELECT substring(value from E'\\d+')::integer
-                FROM actor.org_unit_ancestor_setting('cat.default_classification_scheme', NEW.owning_lib)
-            ), 1
-        );
-    END IF;
-
-    EXECUTE 'SELECT ' || acnc.normalizer || '(' || 
-       quote_literal( NEW.label ) || ')'
-       FROM asset.call_number_class acnc
-       WHERE acnc.id = NEW.label_class
-       INTO sortkey;
-    NEW.label_sortkey = sortkey;
-    RETURN NEW;
-END;
-$func$ LANGUAGE PLPGSQL;
-
-
-COMMIT;