--- /dev/null
+BEGIN;
+ SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ --create config.hold_type table
+ CREATE TABLE config.hold_type (
+ type text NOT NULL,
+ name text NOT NULL,
+ description text,
+ CONSTRAINT hold_type_pkey PRIMARY KEY (type)
+ );
+
+ --insert base hold types
+ INSERT INTO config.hold_type (type, name, description) VALUES
+ ('C', 'Copy', 'Copy Level Hold'),
+ ('F', 'Force', 'Copy Level Hold - Bypasses Hold Rules'),
+ ('R', 'Recall', 'Cataloger''s Recall - Copy Level Hold - Bypasses Hold Rules - Goes to Cataloging at capture'),
+ ('T', 'Title', 'Bib Level Hold'),
+ ('M', 'Metarecord', 'Metarecord Level Hold'),
+ ('V', 'Volume', 'Volume (Call Number) Level Hold'),
+ ('I', 'Issuance', 'Issuance Level Hold'),
+ ('P', 'Part', 'Part Level Hold');
+
+ --remove config.hold_type table
+ --DROP TABLE config.hold_type;
+
+ --convert all hold_types in action.hold_request to uppercase
+ --UPDATE action.hold_request
+ --SET hold_type = upper(hold_type)
+ --WHERE hold_type ~ '[a-z]';
+
+ --get all hold_types in action.hold_request that are not in config.hold_type
+ SELECT DISTINCT ahr.hold_type invalid_types
+ FROM action.hold_request AS ahr
+ EXCEPT SELECT type FROM config.hold_type;
+
+ --create foreign key
+ ALTER TABLE action.hold_request ADD CONSTRAINT hold_type_fkey FOREIGN KEY (hold_type) REFERENCES config.hold_type (type) MATCH FULL;
+
+ --remove foreign key
+ --ALTER TABLE action.hold_request DROP CONSTRAINT hold_type_fkey;
+
+COMMIT;