a631f4140f4323fa058f3ff3a1a690df6a698dac
[koha-equinox.git] / installer / data / mysql / atomicupdate / bug_22521.perl
1 $DBversion = 'XXX';    # will be replaced by the RM
2 if ( CheckVersion($DBversion) ) {
3
4     if ( column_exists( 'accountlines', 'accounttype' ) ) {
5         $dbh->do(
6             qq{
7             ALTER TABLE `accountlines`
8             CHANGE COLUMN `accounttype`
9               `accounttype` varchar(16) DEFAULT NULL;
10           }
11         );
12     }
13
14     $dbh->do(qq{
15         UPDATE
16           accountlines
17         SET
18           accounttype = 'OVERDUE',
19           status = 'UNRETURNED'
20         WHERE
21           accounttype = 'FU';
22     });
23
24     $dbh->do(qq{
25         UPDATE
26           accountlines
27         SET
28           accounttype = 'OVERDUE',
29           status = 'FORGIVEN'
30         WHERE
31           accounttype = 'FFOR';
32     });
33
34     $dbh->do(qq{
35         UPDATE
36           accountlines
37         SET
38           accounttype = 'OVERDUE',
39           status = 'RETURNED'
40         WHERE
41           accounttype = 'F';
42     });
43     SetVersion($DBversion);
44     print "Upgrade to $DBversion done (Bug 22521 - Update accountlines.accounttype to varchar(16), and map new statuses)\n";
45 }