Bug 37601: Add status field to bookings table
Signed-off-by: LEBSimonsen <simonsen@bz-sh.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
750f40eaae
commit
0846e45a1e
|
|
@ -0,0 +1,28 @@
|
|||
use Modern::Perl;
|
||||
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
|
||||
|
||||
return {
|
||||
bug_number => '37601',
|
||||
description => 'Add status column to bookings table',
|
||||
up => sub {
|
||||
my ($args) = @_;
|
||||
my ( $dbh, $out ) = @{$args}{qw(dbh out)};
|
||||
|
||||
if ( column_exists( 'bookings', 'status' ) ) {
|
||||
say_info( $out, q{Column 'status' already exists in 'bookings' table. Skipping...} );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
my $after = 'AFTER' . ( column_exists( 'bookings', 'updated_at' ) ? q{`updated_at`} : q{`end_date`} );
|
||||
my $statement = <<~"SQL";
|
||||
ALTER TABLE `bookings`
|
||||
ADD COLUMN `status` ENUM('created', 'cancelled') NOT NULL DEFAULT 'created' COMMENT 'current status of the booking' $after;
|
||||
SQL
|
||||
if ( $dbh->do($statement) ) {
|
||||
say_success( $out, q{Added column 'bookings.status'} );
|
||||
} else {
|
||||
say_failure( $out, q{Failed to add column 'bookings.status'} );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -1219,6 +1219,7 @@ CREATE TABLE `bookings` (
|
|||
`end_date` datetime DEFAULT NULL COMMENT 'the end date of the booking',
|
||||
`creation_date` timestamp DEFAULT current_timestamp() COMMENT 'the timestamp for when a booking was created',
|
||||
`modification_date` timestamp DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'the timestamp for when a booking has been updated',
|
||||
`status` enum('created', 'cancelled') NOT NULL DEFAULT 'created' COMMENT 'current status of the booking',
|
||||
PRIMARY KEY (`booking_id`),
|
||||
KEY `patron_id` (`patron_id`),
|
||||
KEY `biblio_id` (`biblio_id`),
|
||||
|
|
|
|||
Loading…
Reference in New Issue