Line 0
Link Here
|
0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
|
3 |
return { |
4 |
bug_number => "6796", |
5 |
description => "Overnight checkouts taking into account opening and closing hours", |
6 |
up => sub { |
7 |
my ($args) = @_; |
8 |
my ($dbh, $out) = @$args{qw(dbh out)}; |
9 |
|
10 |
unless( TableExists('branch_hours') ) { |
11 |
$dbh->do(q{ |
12 |
CREATE TABLE branch_hours ( |
13 |
branchcode varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, |
14 |
day int(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0, |
15 |
open_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL, |
16 |
close_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL, |
17 |
PRIMARY KEY (branchcode, day), |
18 |
CONSTRAINT branch_hours_ibfk_1 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE |
19 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |
20 |
}); |
21 |
|
22 |
my @indexes = (0..6); |
23 |
for my $i (@indexes) { |
24 |
$dbh->do(q{ INSERT INTO branch_hours (branchcode, day) SELECT branchcode, ? FROM branches }, undef, $i); |
25 |
} |
26 |
|
27 |
say $out "Added table `branch_hours`"; |
28 |
} |
29 |
}, |
30 |
}; |