Bug 22600: Add 'interface' to accountlines
[koha.git] / installer / data / mysql / atomicupdate / bug_22600.perl
1 $DBversion = 'XXX';    # will be replaced by the RM
2 if ( CheckVersion($DBversion) ) {
3
4     if ( !column_exists( 'accountlines', 'interface' ) ) {
5         $dbh->do(
6             qq{
7             ALTER TABLE `accountlines`
8             ADD
9               `interface` varchar(16)
10             AFTER
11               `manager_id`;
12           }
13         );
14     }
15
16     $dbh->do(qq{
17         UPDATE
18           `accountlines`
19         SET
20           interface = 'opac'
21         WHERE
22           borrowernumber = manager_id;
23     });
24
25     $dbh->do(qq{
26         UPDATE
27           `accountlines`
28         SET
29           interface = 'cron'
30         WHERE
31           manager_id IS NULL
32         AND
33           branchcode IS NULL;
34     });
35
36     $dbh->do(qq{
37         UPDATE
38           `accountlines`
39         SET
40           interface = 'intranet'
41         WHERE
42           interface IS NULL;
43     });
44
45     $dbh->do(qq{
46         ALTER TABLE `accountlines`
47         MODIFY COLUMN `interface` varchar(16) NOT NULL;
48     });
49
50     SetVersion($DBversion);
51     print "Upgrade to $DBversion done (Bug 22600 - Add interface to accountlines)\n";
52 }