RETURNS TRIGGER AS $func$
BEGIN
INSERT INTO auditor.$$ || sch || $$_$$ || tbl || $$_history
- SELECT nextval('auditor.$$ || sch || $$_$$ || tbl || $$_pkey_seq'),
+ SELECT nextval('auditor.$$ || sch || $$_$$ || tbl || $$_pkey_seq' ),
now(),
SUBSTR(TG_OP,1,1),
OLD.*;
COMMIT;
+-- remove all data from config.metabib_field and replace with seed values for 1.6
+-- and customized pines data with id numbers above 100
+BEGIN;
+DELETE FROM config.metabib_field;
+
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 1, 'series', 'seriestitle', 'mods32', $$//mods32:mods/mods32:relatedItem[@type="series"]/mods32:titleInfo$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 2, 'title', 'abbreviated', 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='abbreviated' )]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 3, 'title', 'translated', 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='translated' )]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 4, 'title', 'alternative', 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='alternative' )]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 5, 'title', 'uniform', 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and (@type='uniform' )]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 6, 'title', 'proper', 'mods32', $$//mods32:mods/mods32:titleInfo[mods32:title and not (@type)]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 7, 'author', 'corporate', 'mods32', $$//mods32:mods/mods32:name[@type='corporate']/mods32:namePart[../mods32:role/mods32:roleTerm[text()='creator']]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 8, 'author', 'personal', 'mods32', $$//mods32:mods/mods32:name[@type='personal']/mods32:namePart[../mods32:role/mods32:roleTerm[text()='creator']]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 9, 'author', 'conference', 'mods32', $$//mods32:mods/mods32:name[@type='conference']/mods32:namePart[../mods32:role/mods32:roleTerm[text()='creator']]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 10, 'author', 'other', 'mods32', $$//mods32:mods/mods32:name[@type='personal']/mods32:namePart[not(../mods32:role)]$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 11, 'subject', 'geographic', 'mods32', $$//mods32:mods/mods32:subject/mods32:geographic$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 12, 'subject', 'name', 'mods32', $$//mods32:mods/mods32:subject/mods32:name$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 13, 'subject', 'temporal', 'mods32', $$//mods32:mods/mods32:subject/mods32:temporal$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 14, 'subject', 'topic', 'mods32', $$//mods32:mods/mods32:subject/mods32:topic$$ );
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 15, 'keyword', 'keyword', 'mods32', $$//mods32:mods/*[not(local-name()='originInfo' )]$$ ); -- /* to fool vim */;
+INSERT INTO config.metabib_field ( id, field_class, name, format, xpath ) VALUES
+ ( 16, 'subject', 'complete', 'mods32', $$//mods32:mods/mods32:subject//text()$$ );
+
+-- custom PINES fields:
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 120, 'title', '222', $$//marcxml:datafield[@tag="222"]/marcxml:subfield[contains("ab",@code)]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 121, 'title', '243', $$//marcxml:datafield[@tag="243"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 122, 'title', '240', $$//marcxml:datafield[@tag="240"]/marcxml:subfield[contains("gn",@code)]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 123, 'title', '246', $$//marcxml:datafield[@tag="246"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 124, 'title', '247', $$//marcxml:datafield[@tag="247"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 126, 'title', '730', $$//marcxml:datafield[@tag="730"]/marcxml:subfield[contains("gn",@code)]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 127, 'title', '740', $$//marcxml:datafield[@tag="740"]/marcxml:subfield[contains("anp",@code)]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 131, 'title', '505t', $$//marcxml:datafield[@tag="505"]/marcxml:subfield[@code="t"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 133, 'subject', '655', $$//marcxml:datafield[@tag="655"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 134, 'subject', '690', $$//marcxml:datafield[@tag="690"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 135, 'subject', '654', $$//marcxml:datafield[@tag="654"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 136, 'subject', '657', $$//marcxml:datafield[@tag="657"]$$, 1, 'marcxml', 't', 'f' );
+INSERT INTO config.metabib_field ( id, field_class, name, xpath, weight, format, search_field, facet_field ) VALUES
+ ( 137, 'subject', '658', $$//marcxml:datafield[@tag="658"]$$, 1, 'marcxml', 't', 'f' );
+
+COMMIT;
+
-- These are restored by the post-upgrade PINES sql script.