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 ('1162', :eg_version); -- berick/Bmagic
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1163', :eg_version); -- JBoyer/Dyrcona/bshum/JBoyer
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
--- /dev/null
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1163', :eg_version); -- JBoyer/Dyrcona/bshum/JBoyer
+
+CREATE OR REPLACE FUNCTION vandelay.flatten_marc_hstore(
+ record_xml TEXT
+) RETURNS HSTORE AS $func$
+BEGIN
+ RETURN (SELECT
+ HSTORE(
+ ARRAY_AGG(tag || (COALESCE(subfield, ''))),
+ ARRAY_AGG(value)
+ )
+ FROM (
+ SELECT tag, subfield, ARRAY_AGG(value)::TEXT AS value
+ FROM (SELECT tag,
+ subfield,
+ CASE WHEN tag = '020' THEN -- caseless -- isbn
+ LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{10,17})$$))[1] || '%')
+ WHEN tag = '022' THEN -- caseless -- issn
+ LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
+ WHEN tag = '024' THEN -- caseless -- upc (other)
+ LOWER(value || '%')
+ ELSE
+ value
+ END AS value
+ FROM vandelay.flatten_marc(record_xml)) x
+ GROUP BY tag, subfield ORDER BY tag, subfield
+ ) subquery
+ );
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
+++ /dev/null
-BEGIN;
-
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION vandelay.flatten_marc_hstore(
- record_xml TEXT
-) RETURNS HSTORE AS $func$
-BEGIN
- RETURN (SELECT
- HSTORE(
- ARRAY_AGG(tag || (COALESCE(subfield, ''))),
- ARRAY_AGG(value)
- )
- FROM (
- SELECT tag, subfield, ARRAY_AGG(value)::TEXT AS value
- FROM (SELECT tag,
- subfield,
- CASE WHEN tag = '020' THEN -- caseless -- isbn
- LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{10,17})$$))[1] || '%')
- WHEN tag = '022' THEN -- caseless -- issn
- LOWER((SELECT REGEXP_MATCHES(value,$$^(\S{4}[- ]?\S{4})$$))[1] || '%')
- WHEN tag = '024' THEN -- caseless -- upc (other)
- LOWER(value || '%')
- ELSE
- value
- END AS value
- FROM vandelay.flatten_marc(record_xml)) x
- GROUP BY tag, subfield ORDER BY tag, subfield
- ) subquery
- );
-END;
-$func$ LANGUAGE PLPGSQL;
-
-COMMIT;