Bug 18936: (follow-up) fix tests, null vs. empty behavior for limiting rules
[koha.git] / installer / data / mysql / atomicupdate / bug_18936.perl
1 $DBversion = 'XXX';  # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3     my @columns = qw(
4         restrictedtype
5         rentaldiscount
6         fine
7         finedays
8         maxsuspensiondays
9         firstremind
10         chargeperiod
11         chargeperiod_charge_at
12         accountsent
13         issuelength
14         lengthunit
15         hardduedate
16         hardduedatecompare
17         renewalsallowed
18         renewalperiod
19         norenewalbefore
20         auto_renew
21         no_auto_renewal_after
22         no_auto_renewal_after_hard_limit
23         reservesallowed
24         holds_per_record
25         overduefinescap
26         cap_fine_to_replacement_price
27         onshelfholds
28         opacitemholds
29         article_requests
30         maxissueqty
31         maxonsiteissueqty
32     );
33
34     if ( column_exists( 'issuingrules', 'categorycode' ) ) {
35         foreach my $column ( @columns ) {
36             $dbh->do("
37                 INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value )
38                 SELECT categorycode, branchcode, itemtype, \'$column\', COALESCE( $column, '' )
39                 FROM issuingrules
40             ");
41         }
42         $dbh->do("DROP TABLE issuingrules");
43     }
44
45     SetVersion( $DBversion );
46     print "Upgrade to $DBversion done (Bug 18936: Convert issuingrules fields to circulation_rules)\n";
47 }