<field reporter:label="Matchpoint ID" name="id" reporter:datatype="id"/>
<field reporter:label="Renewal?" name="is_renewal" reporter:datatype="bool"/>
<field reporter:label="Active?" name="active" reporter:datatype="bool"/>
- <field reporter:label="Org Unit" name="org_unit" reporter:datatype="org_unit" oils_obj:required="true"/>
+ <field reporter:label="Org Unit" name="org_unit" reporter:datatype="org_unit" oils_persist:primitive="array" oils_obj:required="true"/>
<field reporter:label="Copy Circ Lib" name="copy_circ_lib" reporter:datatype="org_unit"/>
<field reporter:label="Copy Owning Lib" name="copy_owning_lib" reporter:datatype="org_unit"/>
<field reporter:label="User Home Lib" name="user_home_ou" reporter:datatype="org_unit"/>
** developers focus on specific parts of the matrix.
**/
-CREATE TABLE config.circ_matrix_matchpoint (
+CREATE TABLE config.circ_matrix_matchpoint_base (
id SERIAL PRIMARY KEY,
active BOOL NOT NULL DEFAULT TRUE,
-- Match Fields
- org_unit INT NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
+ org_unit INT[] NOT NULL, -- Set to an array of the top OU for the matchpoint applicability range; we can use org_unit_prox to choose the "best"
grp INT NOT NULL REFERENCES permission.grp_tree (id) DEFERRABLE INITIALLY DEFERRED, -- Set to the top applicable group from the group tree; will need descendents and prox functions for filtering
circ_modifier TEXT REFERENCES config.circ_modifier (code) DEFERRABLE INITIALLY DEFERRED,
copy_location INT REFERENCES asset.copy_location (id) DEFERRABLE INITIALLY DEFERRED,
);
-- Nulls don't count for a constraint match, so we have to coalesce them into something that does.
-CREATE UNIQUE INDEX ccmm_once_per_paramset ON config.circ_matrix_matchpoint (org_unit, grp, COALESCE(circ_modifier, ''), COALESCE(copy_location::TEXT, ''), COALESCE(marc_type, ''), COALESCE(marc_form, ''), COALESCE(marc_bib_level,''), COALESCE(marc_vr_format, ''), COALESCE(copy_circ_lib::TEXT, ''), COALESCE(copy_owning_lib::TEXT, ''), COALESCE(user_home_ou::TEXT, ''), COALESCE(ref_flag::TEXT, ''), COALESCE(juvenile_flag::TEXT, ''), COALESCE(is_renewal::TEXT, ''), COALESCE(usr_age_lower_bound::TEXT, ''), COALESCE(usr_age_upper_bound::TEXT, ''), COALESCE(item_age::TEXT, '')) WHERE active;
+CREATE UNIQUE INDEX ccmm_once_per_paramset ON config.circ_matrix_matchpoint_base (org_unit, grp, COALESCE(circ_modifier, ''), COALESCE(copy_location::TEXT, ''), COALESCE(marc_type, ''), COALESCE(marc_form, ''), COALESCE(marc_bib_level,''), COALESCE(marc_vr_format, ''), COALESCE(copy_circ_lib::TEXT, ''), COALESCE(copy_owning_lib::TEXT, ''), COALESCE(user_home_ou::TEXT, ''), COALESCE(ref_flag::TEXT, ''), COALESCE(juvenile_flag::TEXT, ''), COALESCE(is_renewal::TEXT, ''), COALESCE(usr_age_lower_bound::TEXT, ''), COALESCE(usr_age_upper_bound::TEXT, ''), COALESCE(item_age::TEXT, '')) WHERE active;
+
+-- Backword compat view
+CREATE VIEW config.circ_matrix_matchpoint AS
+ SELECT id,
+ active,
+ UNNEST(org_unit) AS org_unit,
+ grp,
+ circ_modifier,
+ copy_location,
+ marc_type,
+ marc_form,
+ marc_bib_level,
+ marc_vr_format,
+ copy_circ_lib,
+ copy_owning_lib,
+ user_home_ou,
+ ref_flag,
+ juvenile_flag,
+ is_renewal,
+ usr_age_lower_bound,
+ usr_age_upper_bound,
+ item_age,
+ circulate,
+ duration_rule,
+ recurring_fine_rule,
+ max_fine_rule,
+ hard_due_date,
+ renewals,
+ grace_period,
+ script_test,
+ total_copy_hold_ratio,
+ available_copy_hold_ratio
+ FROM config.circ_matrix_matchpoint_base;
-- Limit groups for circ counting
CREATE TABLE config.circ_limit_group (