View | Details | Raw Unified | Return to bug 37601
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_37601-add-status-field-to-bookings-table.pl (+28 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => '37601',
6
    description => 'Add status column to bookings table',
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @{$args}{qw(dbh out)};
10
11
        if ( column_exists( 'bookings', 'status' ) ) {
12
            say_info( $out, q{Column 'status' already exists in 'bookings' table. Skipping...} );
13
14
            return;
15
        }
16
17
        my $after     = 'AFTER' . ( column_exists( 'bookings', 'updated_at' ) ? q{`updated_at`} : q{`end_date`} );
18
        my $statement = <<~"SQL";
19
            ALTER TABLE `bookings`
20
            ADD COLUMN `status` ENUM('created', 'cancelled') NOT NULL DEFAULT 'created' COMMENT 'current status of the booking' $after;
21
        SQL
22
        if ( $dbh->do($statement) ) {
23
            say_success( $out, q{Added column 'bookings.status'} );
24
        } else {
25
            say_failure( $out, q{Failed to add column 'bookings.status'} );
26
        }
27
    },
28
};
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 1217-1222 CREATE TABLE `bookings` ( Link Here
1217
  `pickup_library_id` varchar(10) NOT NULL COMMENT 'Identifier for booking pickup library',
1217
  `pickup_library_id` varchar(10) NOT NULL COMMENT 'Identifier for booking pickup library',
1218
  `start_date` datetime DEFAULT NULL COMMENT 'the start date of the booking',
1218
  `start_date` datetime DEFAULT NULL COMMENT 'the start date of the booking',
1219
  `end_date` datetime DEFAULT NULL COMMENT 'the end date of the booking',
1219
  `end_date` datetime DEFAULT NULL COMMENT 'the end date of the booking',
1220
  `status` enum('created', 'cancelled') NOT NULL DEFAULT 'created' COMMENT 'current status of the booking',
1220
  PRIMARY KEY (`booking_id`),
1221
  PRIMARY KEY (`booking_id`),
1221
  KEY `patron_id` (`patron_id`),
1222
  KEY `patron_id` (`patron_id`),
1222
  KEY `biblio_id` (`biblio_id`),
1223
  KEY `biblio_id` (`biblio_id`),
1223
- 

Return to bug 37601