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,
--- /dev/null
+-- 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;
--- /dev/null
+-- 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;
+++ /dev/null
--- 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;
+++ /dev/null
--- 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;