From 838f30e150dd1c589ed9a2cb7dc8494b467c63de Mon Sep 17 00:00:00 2001 From: Michele Morgan Date: Mon, 3 Jul 2017 14:49:42 -0400 Subject: [PATCH] LP 1075401 - Upgrade script to nullify existing bad data Sets to NULL any entries in asset.copy_template.age_protect and asset.copy_template.circ_as_type that are not valid values. Signed-off-by: Michele Morgan Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- ...fy_invalid_act.age_protect_act.circ_as_type.sql | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.nullify_invalid_act.age_protect_act.circ_as_type.sql diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.nullify_invalid_act.age_protect_act.circ_as_type.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.nullify_invalid_act.age_protect_act.circ_as_type.sql new file mode 100644 index 0000000000..7eafe1194a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.nullify_invalid_act.age_protect_act.circ_as_type.sql @@ -0,0 +1,35 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +\echo ----------------------------------------------------------- +\echo Setting invalid age_protect and circ_as_type entries to NULL, +\echo otherwise they will break the Serial Copy Templates editor. +\echo Please review any Serial Copy Templates listed below. +\echo +UPDATE asset.copy_template act +SET age_protect = NULL +FROM actor.org_unit aou +WHERE aou.id=act.owning_lib + AND act.age_protect NOT IN + ( + SELECT id FROM config.rule_age_hold_protect + ) +RETURNING act.id "Template ID", act.name "Template Name", + aou.shortname "Owning Lib", + 'Age Protection value reset to null.' "Description"; + +UPDATE asset.copy_template act +SET circ_as_type = NULL +FROM actor.org_unit aou +WHERE aou.id=act.owning_lib + AND act.circ_as_type NOT IN + ( + SELECT code FROM config.item_type_map + ) +RETURNING act.id "Template ID", act.name "Template Name", + aou.shortname "Owning Lib", + 'Circ as Type value reset to null.' as "Description"; + +\echo -----------End Serial Template Fix---------------- +COMMIT; -- 2.11.0