From: Chris Sharp Date: Mon, 30 Aug 2021 16:31:18 +0000 (-0400) Subject: add script for changing AV circ mods X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=97a3e3c2358dc00e22a2279d595ed8f6b34040e3;p=contrib%2Fpines.git add script for changing AV circ mods Signed-off-by: Chris Sharp --- diff --git a/sql/av_circ_mod_changes_2021_09.sql b/sql/av_circ_mod_changes_2021_09.sql new file mode 100644 index 0000000..07aa87e --- /dev/null +++ b/sql/av_circ_mod_changes_2021_09.sql @@ -0,0 +1,219 @@ +begin; + + +-- Physical music sound recordings +-- +-- music (existing) +-- music-ff (create) +-- +-- Physical spoken word sound recordings +-- +-- audiobook (existing) +-- audiobook-ff (create) +-- +-- Physical recorded visual material +-- +-- video-0 (new - editing dvd-0) +-- video-0-ff (create) +-- video-2 (new - editing dvd-2) +-- video-2-ff (new - editing dvd-2-ff) + + + +-- create new circ mods +insert into config.circ_modifier ( + code, + name, + description, + sip2_media_type +) values ( + 'audiobook-ff', + 'audiobook-ff', + 'Physical spoken word sound recordings - no fines accrued', + '004' +), + ( + 'video-0-ff', + 'video-0-ff', + 'Physical recorded visual material - no fines accrued', + '004' + + ); + +-- create circ rules +insert into config.circ_matrix_matchpoint ( + org_unit, + grp, + circ_modifier, + ref_flag, + circulate, + duration_rule, + recurring_fine_rule, + max_fine_rule +) values ( + 1, + 1, + 'audiobook-ff', + false, + true, + (select id from config.rule_circ_duration where name = '14_days_2_renew'), + (select id from config.rule_recurring_fine where name = 'no_fines'), + (select id from config.rule_max_fine where name = 'no_fines') +),( + 1, + 1, + 'video-0-ff', + false, + true, + (select id from config.rule_circ_duration where name = '7_or_14_day_0_renew'), + (select id from config.rule_recurring_fine where name = 'no_fines'), + (select id from config.rule_max_fine where name = 'no_fines') +); + +-- circ limit sets +insert into config.circ_limit_set_circ_mod_map ( + limit_set, + circ_mod +) values ( + (select id from config.circ_limit_set where name = 'Video Limits'), + 'video-0-ff' +); +update config.circ_limit_set_circ_mod_map set limit_set = (select id from config.circ_limit_set where name = 'Video Limits') where circ_mod in ('dvd-2-ff', 'dvd-0', 'dvd-2'); +update config.circ_matrix_limit_set_map set limit_set = (select id from config.circ_limit_set where name = 'Video Limits') where matchpoint in (select id from config.circ_matrix_matchpoint where circ_modifier in ('dvd-2-ff', 'dvd-0', 'dvd-2')); + +-- hold policies +insert into config.hold_matrix_matchpoint ( + user_home_ou, + pickup_ou, + item_owning_ou, + requestor_grp, + circ_modifier, + ref_flag, + transit_range, + max_holds +) values ( + 1, + null, + null, + 1, + 'audiobook-ff', + false, + 2, + 50 +),( + null, + 115, + 33, + 1, + 'audiobook-ff', + false, + null, + 50 +),( + null, + 33, + 115, + 1, + 'audiobook-ff', + false, + null, + 50 +),( + null, + 115, + 33, + 1, + 'video-0-ff', + false, + null, + 50 +),( + null, + 33, + 115, + 1, + 'video-0-ff', + false, + null, + 50 +),( + 1, + null, + null, + 1, + 'video-0-ff', + false, + 2, + 50 +),( +-- also adding some missing hold policies + 1, + null, + null, + 1, + 'toy', + false, + 2, + 50 +),( + 1, + null, + null, + 1, + 'art', + false, + 2, + 50 +),( + 1, + null, + null, + 1, + 'map', + false, + 2, + 50 +),( + 1, + null, + null, + 1, + 'talking book', + false, + null, + 50 +); + +-- alter the distribution formula entry constraint so we can change stuff +alter table acq.distribution_formula_entry alter constraint distribution_formula_entry_circ_modifier_fkey deferrable initially deferred; + +-- dvd-0 to video-0 +update config.circ_modifier set code = 'video-0', description = 'Visual items with no renewals', magnetic_media = true, name = 'video-0' where code = 'dvd-0'; +update acq.lineitem_detail set circ_modifier = 'video-0' where circ_modifier = 'dvd-0'; +update acq.distribution_formula_entry set circ_modifier = 'video-0' where circ_modifier = 'dvd-0'; +update config.circ_matrix_matchpoint set circ_modifier = 'video-0' where circ_modifier = 'dvd-0'; +update config.hold_matrix_matchpoint set circ_modifier = 'video-0' where circ_modifier = 'dvd-0'; +update config.circ_limit_set_circ_mod_map SET circ_mod = 'video-0' where circ_mod = 'dvd-0'; + +-- dvd-2 to video-2 +update config.circ_modifier set code = 'video-2', description = 'Visual items', magnetic_media = true, name = 'video-2' where code = 'dvd-2'; +update acq.lineitem_detail set circ_modifier = 'video-2' where circ_modifier = 'dvd-2'; +update acq.distribution_formula_entry set circ_modifier = 'video-2' where circ_modifier = 'dvd-2'; +update config.circ_matrix_matchpoint set circ_modifier = 'video-2' where circ_modifier = 'dvd-2'; +update config.hold_matrix_matchpoint set circ_modifier = 'video-2' where circ_modifier = 'dvd-2'; +update config.circ_limit_set_circ_mod_map SET circ_mod = 'video-2' where circ_mod = 'dvd-2'; + +-- dvd-2-ff to video-2-ff +update config.circ_modifier set code = 'video-2-ff', description = 'Visual items - no fines accrued', magnetic_media = true, name = 'video-2-ff' where code = 'dvd-2-ff'; +update acq.lineitem_detail set circ_modifier = 'video-2-ff' where circ_modifier = 'dvd-2-ff'; +update acq.distribution_formula_entry set circ_modifier = 'video-2-ff' where circ_modifier = 'dvd-2-ff'; +update config.circ_matrix_matchpoint set circ_modifier = 'video-2-ff' where circ_modifier = 'dvd-2-ff'; +update config.hold_matrix_matchpoint set circ_modifier = 'video-2-ff' where circ_modifier = 'dvd-2-ff'; +update config.circ_limit_set_circ_mod_map SET circ_mod = 'video-2-ff' where circ_mod = 'dvd-2-ff'; + + +commit; + +-- change the acq table back to what it was +alter table acq.distribution_formula_entry alter constraint distribution_formula_entry_circ_modifier_fkey not deferrable; +