From fd705d123296c4a363364870bff55e8d33316deb Mon Sep 17 00:00:00 2001 From: Kevin Carnes Date: Tue, 11 Oct 2022 09:24:40 +0200 Subject: [PATCH] Bug 31727: Orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing --- .../data/mysql/atomicupdate/bug_31727.pl | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_31727.pl diff --git a/installer/data/mysql/atomicupdate/bug_31727.pl b/installer/data/mysql/atomicupdate/bug_31727.pl new file mode 100755 index 0000000000..375116ea73 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31727.pl @@ -0,0 +1,29 @@ +use Modern::Perl; + +return { + bug_number => "31727", + description => "Orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + for my $rule_name ( qw( issuelength hardduedate unseenrenewalsallowed rentaldiscount decreaseloanholds ) ) { + $dbh->do(q{ + DELETE FROM circulation_rules WHERE id in ( + SELECT id FROM ( + SELECT id FROM circulation_rules cr WHERE rule_name = ? AND NOT EXISTS ( + SELECT NULL FROM circulation_rules cr2 + WHERE + cr2.rule_name="suspension_chargeperiod" + 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 orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing"; + $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