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 ('1086', :eg_version); -- miker/kmlussier
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1157', :eg_version); -- berick/sandbergja/Dyrcona
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
field_class TEXT NOT NULL REFERENCES config.metabib_class (name),
name TEXT NOT NULL,
label TEXT NOT NULL,
- xpath TEXT NOT NULL,
+ xpath TEXT,
weight INT NOT NULL DEFAULT 1,
format TEXT NOT NULL REFERENCES config.xml_transform (name) DEFAULT 'mods33',
search_field BOOL NOT NULL DEFAULT TRUE,
authority_xpath TEXT,
joiner TEXT,
restrict BOOL DEFAULT FALSE NOT NULL,
- display_field BOOL NOT NULL DEFAULT FALSE
+ display_field BOOL NOT NULL DEFAULT TRUE
);
COMMENT ON TABLE config.metabib_field IS $$
XPath used for record indexing ingest
or identifier.
$$;
+CREATE TABLE config.metabib_field_virtual_map (
+ id SERIAL PRIMARY KEY,
+ real INT NOT NULL REFERENCES config.metabib_field (id),
+ virtual INT NOT NULL REFERENCES config.metabib_field (id),
+ weight INT NOT NULL DEFAULT 1
+);
+COMMENT ON TABLE config.metabib_field_virtual_map IS $$
+Maps between real (physically extracted) index definitions
+and virtual (target sync, no required extraction of its own)
+index definitions.
+
+The virtual side may not extract any data of its own, but
+will collect data from all of the real fields. This reduces
+extraction (ingest) overhead by eliminating duplcated extraction,
+and allows for searching across novel combinations of fields, such
+as names used as either subjects or authors. By preserving this
+mapping rather than defining duplicate extractions, information
+about the originating, "real" index definitions can be used
+in interesting ways, such as highlighting in search results.
+$$;
+
CREATE UNIQUE INDEX config_metabib_field_class_name_idx ON config.metabib_field (field_class, name);
CREATE TABLE config.display_field_map (
extended INTERVAL NOT NULL,
normal INTERVAL NOT NULL,
shrt INTERVAL NOT NULL,
- max_renewals INT NOT NULL
+ max_renewals INT NOT NULL,
+ max_auto_renewals INTEGER
);
COMMENT ON TABLE config.rule_circ_duration IS $$
Circulation Duration rules
);
+CREATE TABLE config.workstation_setting_type (
+ name TEXT PRIMARY KEY,
+ label TEXT UNIQUE NOT NULL,
+ grp TEXT REFERENCES config.settings_group (name),
+ description TEXT,
+ datatype TEXT NOT NULL DEFAULT 'string',
+ fm_class TEXT,
+ --
+ -- define valid datatypes
+ --
+ CONSTRAINT cwst_valid_datatype CHECK ( datatype IN
+ ( 'bool', 'integer', 'float', 'currency', 'interval',
+ 'date', 'string', 'object', 'array', 'link' ) ),
+ --
+ -- fm_class is meaningful only for 'link' datatype
+ --
+ CONSTRAINT cwst_no_empty_link CHECK
+ ( ( datatype = 'link' AND fm_class IS NOT NULL ) OR
+ ( datatype <> 'link' AND fm_class IS NULL ) )
+);
+
+-- Prevent setting types from being both user and workstation settings.
+CREATE OR REPLACE FUNCTION config.setting_is_user_or_ws()
+RETURNS TRIGGER AS $FUNC$
+BEGIN
+
+ IF TG_TABLE_NAME = 'usr_setting_type' THEN
+ PERFORM TRUE FROM config.workstation_setting_type cwst
+ WHERE cwst.name = NEW.name;
+ IF NOT FOUND THEN
+ RETURN NULL;
+ END IF;
+ END IF;
+
+ IF TG_TABLE_NAME = 'workstation_setting_type' THEN
+ PERFORM TRUE FROM config.usr_setting_type cust
+ WHERE cust.name = NEW.name;
+ IF NOT FOUND THEN
+ RETURN NULL;
+ END IF;
+ END IF;
+
+ RAISE EXCEPTION
+ '% Cannot be used as both a user setting and a workstation setting.',
+ NEW.name;
+END;
+$FUNC$ LANGUAGE PLPGSQL STABLE;
+
+CREATE CONSTRAINT TRIGGER check_setting_is_usr_or_ws
+ AFTER INSERT OR UPDATE ON config.usr_setting_type
+ FOR EACH ROW EXECUTE PROCEDURE config.setting_is_user_or_ws();
+
+CREATE CONSTRAINT TRIGGER check_setting_is_usr_or_ws
+ AFTER INSERT OR UPDATE ON config.workstation_setting_type
+ FOR EACH ROW EXECUTE PROCEDURE config.setting_is_user_or_ws();
+
+
+
-- Some handy functions, based on existing ones, to provide optional ingest normalization
CREATE OR REPLACE FUNCTION public.left_trunc( TEXT, INT ) RETURNS TEXT AS $func$