Line 0
Link Here
|
0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
|
3 |
return { |
4 |
bug_number => "31727", |
5 |
description => "Orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing", |
6 |
up => sub { |
7 |
my ($args) = @_; |
8 |
my ($dbh, $out) = @$args{qw(dbh out)}; |
9 |
for my $rule_name ( qw( issuelength hardduedate unseenrenewalsallowed rentaldiscount decreaseloanholds ) ) { |
10 |
$dbh->do(q{ |
11 |
DELETE FROM circulation_rules WHERE id in ( |
12 |
SELECT id FROM ( |
13 |
SELECT id FROM circulation_rules cr WHERE rule_name = ? AND NOT EXISTS ( |
14 |
SELECT NULL FROM circulation_rules cr2 |
15 |
WHERE |
16 |
cr2.rule_name="suspension_chargeperiod" |
17 |
AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) ) |
18 |
AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) ) |
19 |
AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) ) |
20 |
) |
21 |
) AS ids |
22 |
) |
23 |
}, undef, $rule_name); |
24 |
} |
25 |
say $out "Removed orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing"; |
26 |
$dbh->do(q{UPDATE circulation_rules SET rule_name = "unseen_renewals_allowed" WHERE rule_name = "unseenrenewalsallowed"}); |
27 |
say $out "Renamed unseenrenewalsallowed to unseen_renewals_allowed in circulation_rules"; |
28 |
}, |
29 |
} |