Bug 26247: (follow-up) Fix permissions
[koha.git] / installer / data / mysql / db_revs / 220600023.pl
1 use Modern::Perl;
2
3 return {
4     bug_number  => "22456",
5     description => "Allow cancelling waiting holds",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9
10         unless ( TableExists( 'hold_cancellation_requests' ) ) {
11             $dbh->do(q{
12                 CREATE TABLE `hold_cancellation_requests` (
13                 `hold_cancellation_request_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unique ID of the cancellation request',
14                 `hold_id` int(11) NOT null COMMENT 'ID of the hold',
15                 `creation_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Time and date the cancellation request was created',
16                 PRIMARY KEY (`hold_cancellation_request_id`)
17                 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
18             });
19         }
20
21         my ($count) = $dbh->selectrow_array(q{
22                 SELECT COUNT(*)
23                 FROM circulation_rules
24                 WHERE rule_name = 'waiting_hold_cancellation'
25         });
26
27         unless ( $count ) {
28             $dbh->do(q{
29                 INSERT INTO circulation_rules (rule_name, rule_value)
30                 VALUES ('waiting_hold_cancellation', 0)
31             });
32         }
33         else {
34             say $out "Found already existing 'waiting_hold_cancellation' circulation rules on the DB. Please review.";
35         }
36     },
37 };