Koha/installer/data/mysql/db_revs/231200044.pl
Katrin Fischer 1b3a7592c8
Bug 36120: DBRev 23.12.00.044
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-05-03 16:02:54 +02:00

37 lines
1.3 KiB
Perl
Executable file

use Modern::Perl;
return {
bug_number => "36120",
description => "Add pickup location to bookings",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
unless ( column_exists( 'bookings', 'pickup_library_id' ) ) {
$dbh->do(
q{
ALTER TABLE bookings
ADD COLUMN `pickup_library_id` varchar(10) DEFAULT NULL COMMENT 'Identifier for booking pickup library' AFTER `item_id`,
ADD CONSTRAINT `bookings_ibfk_4` FOREIGN KEY (`pickup_library_id`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
}
);
say $out "Added column 'bookings.pickup_library_id'";
$dbh->do(
q{UPDATE bookings JOIN items ON bookings.item_id = items.itemnumber SET bookings.pickup_library_id = items.homebranch }
);
say $out "Set existing bookings pickup location to item homebranch";
$dbh->do(
q{
ALTER TABLE bookings
MODIFY pickup_library_id varchar(10) NOT NULL COMMENT 'Identifier for booking pickup library'
}
);
say $out "Set pickup_library_id to NOT NULL";
}
},
};