Bug 36687: Update itemtypes.notforloan to not allow NULL values and change to tinyint(1)
[koha.git] / installer / data / mysql / atomicupdate / bug_36687.pl
1 use Modern::Perl;
2
3 return {
4     bug_number  => "36687",
5     description => "Set itemtypes.notforloan to NOT NULL and tinyint(1)",
6     up          => sub {
7         my ($args) = @_;
8         my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10         # Do you stuffs here
11         my $count_sql = q{SELECT COUNT(*) FROM itemtypes WHERE notforloan IS NULL};
12         my ($count) = $dbh->selectrow_array($count_sql);
13
14         if ($count) {
15             $dbh->do(q{UPDATE itemtypes SET notforloan = 0 WHERE notforloan IS NULL});
16             say $out "Updated $count columns where itemtypes.notforloan was NULL";
17         }
18         $dbh->do(
19             q{
20              ALTER TABLE itemtypes MODIFY COLUMN `notforloan` tinyint(1) NOT NULL DEFAULT 0
21         }
22         );
23
24         say $out "Updated itemtypes.notforlaon column'";
25     },
26 };