Bug 29002: Add bookings table

This patch adds a new bookings table to store booking details.

Test plan
* Confirm that kohastructure and the atomicupdate match such that an
  install or upgrade result in the same table being present on the
  system.

Sponsored-by: PTFS-Europe
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Janet McGowan <janet.mcgowan@ptfs-europe.com>
Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2021-09-15 16:29:43 +01:00 committed by Tomas Cohen Arazi
parent 29cb60e92a
commit c41b83cfab
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,29 @@
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
});
}
},
}

View file

@ -1195,6 +1195,30 @@ CREATE TABLE `biblioitems` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `bookings`
--
DROP TABLE IF EXISTS `bookings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `borrower_attribute_types`
--