2 ALTER TABLE authority.record_entry DISABLE TRIGGER a_marcxml_is_well_formed;
3 ALTER TABLE authority.record_entry DISABLE TRIGGER aaa_auth_ingest_or_delete;
4 ALTER TABLE authority.record_entry DISABLE TRIGGER b_maintain_901;
5 ALTER TABLE authority.record_entry DISABLE TRIGGER c_maintain_control_numbers;
6 ALTER TABLE authority.record_entry DISABLE TRIGGER map_thesaurus_to_control_set;
10 --SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
12 ALTER TABLE authority.record_entry ADD COLUMN heading TEXT, ADD COLUMN simple_heading TEXT;
14 DROP INDEX IF EXISTS authority.unique_by_heading_and_thesaurus;
15 DROP INDEX IF EXISTS authority.by_heading_and_thesaurus;
16 DROP INDEX IF EXISTS authority.by_heading;
18 -- Update without indexes for HOT update
19 UPDATE authority.record_entry
20 SET heading = authority.normalize_heading( marc ),
21 simple_heading = authority.simple_normalize_heading( marc );
23 CREATE INDEX by_heading_and_thesaurus ON authority.record_entry (heading) WHERE deleted IS FALSE or deleted = FALSE;
24 CREATE INDEX by_heading ON authority.record_entry (simple_heading) WHERE deleted IS FALSE or deleted = FALSE;
27 CREATE OR REPLACE FUNCTION authority.normalize_heading_for_upsert () RETURNS TRIGGER AS $f$
29 NEW.heading := authority.normalize_heading( NEW.marc );
30 NEW.simple_heading := authority.simple_normalize_heading( NEW.marc );
35 CREATE TRIGGER update_headings_tgr BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE authority.normalize_heading_for_upsert();
37 ALTER FUNCTION authority.normalize_heading(TEXT, BOOL) STABLE STRICT;
38 ALTER FUNCTION authority.normalize_heading(TEXT) STABLE STRICT;
39 ALTER FUNCTION authority.simple_normalize_heading(TEXT) STABLE STRICT;
40 ALTER FUNCTION authority.simple_heading_set(TEXT) STABLE STRICT;
45 \qecho This index might fail, and is outside the transaction for that reason.
46 \qecho If it fails, you probably did not have it in the first place.
48 CREATE UNIQUE INDEX unique_by_heading_and_thesaurus ON authority.record_entry (heading) WHERE deleted IS FALSE or deleted = FALSE;
50 ALTER TABLE authority.record_entry ENABLE TRIGGER a_marcxml_is_well_formed;
51 ALTER TABLE authority.record_entry ENABLE TRIGGER aaa_auth_ingest_or_delete;
52 ALTER TABLE authority.record_entry ENABLE TRIGGER b_maintain_901;
53 ALTER TABLE authority.record_entry ENABLE TRIGGER c_maintain_control_numbers;
54 ALTER TABLE authority.record_entry ENABLE TRIGGER map_thesaurus_to_control_set;