/
230600061.pl
executable file
·64 lines (57 loc) · 2.85 KB
/
230600061.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use Modern::Perl;
return {
bug_number => "29002",
description => "Add bookings table",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
if ( !TableExists('bookings') ) {
$dbh->do(
q{
CREATE TABLE `bookings` (
`booking_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`patron_id` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the borrowers table defining which patron this booking is for',
`biblio_id` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblio table defining which bib record this booking is on',
`item_id` int(11) DEFAULT NULL COMMENT 'foreign key from the items table defining the specific item the patron has placed a booking for',
`start_date` datetime DEFAULT NULL COMMENT 'the start date of the booking',
`end_date` datetime DEFAULT NULL COMMENT 'the end date of the booking',
PRIMARY KEY (`booking_id`),
KEY `patron_id` (`patron_id`),
KEY `biblio_id` (`biblio_id`),
KEY `item_id` (`item_id`),
CONSTRAINT `bookings_ibfk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `bookings_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `bookings_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
}
);
say $out "Added new table 'bookings'";
}
if ( !column_exists( 'items', 'bookable' ) ) {
$dbh->do(
q{
ALTER TABLE items ADD COLUMN `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean value defining whether this this item is available for bookings or not' AFTER `barcode`
}
);
say $out "Added column 'items.bookable'";
}
if ( !column_exists( 'deleteditems', 'bookable' ) ) {
$dbh->do(
q{
ALTER TABLE deleteditems ADD COLUMN `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean value defining whether this this item is available for bookings or not' AFTER `barcode`
}
);
say $out "Added column 'deleteditems.bookable'";
}
$dbh->do(
q{
INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (
1,
'manage_bookings',
'Manage item bookings'
);
}
);
say $out "Added new permission 'manage_bookings'";
},
};