From cc5396ee190a15e4913e38e7d0f3f4d7c437318c Mon Sep 17 00:00:00 2001 From: Kevin Carnes Date: Wed, 12 Oct 2022 14:56:49 +0200 Subject: [PATCH] Bug 31727: Remove unseenrenewalsallowed rules that duplicate unseen_renewals_allowed rules --- installer/data/mysql/atomicupdate/bug_31727.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_31727.pl b/installer/data/mysql/atomicupdate/bug_31727.pl index 375116ea73..444cb46f0d 100755 --- a/installer/data/mysql/atomicupdate/bug_31727.pl +++ b/installer/data/mysql/atomicupdate/bug_31727.pl @@ -23,6 +23,21 @@ return { }, undef, $rule_name); } say $out "Removed orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing"; + $dbh->do(q{ + DELETE FROM circulation_rules WHERE id in ( + SELECT id FROM ( + SELECT id FROM circulation_rules cr WHERE rule_name = "unseenrenewalsallowed" AND EXISTS ( + SELECT NULL FROM circulation_rules cr2 + WHERE + cr2.rule_name="unseen_renewals_allowed" + AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) ) + AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) ) + AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) ) + ) + ) AS ids + ) + }, undef, $rule_name); + say $out "Removed unseenrenewalsallowed rules that duplicate unseen_renewals_allowed rules"; $dbh->do(q{UPDATE circulation_rules SET rule_name = "unseen_renewals_allowed" WHERE rule_name = "unseenrenewalsallowed"}); say $out "Renamed unseenrenewalsallowed to unseen_renewals_allowed in circulation_rules"; }, -- 2.25.1