Koha/installer/data/mysql/db_revs/230600055.pl
Tomas Cohen Arazi 5a14db8ac9
Bug 34520: DBRev 23.06.00.055
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-31 11:02:50 -03:00

30 lines
851 B
Perl
Executable file

use Modern::Perl;
return {
bug_number => "34520",
description => "Correct item_groups FK in reserves table",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
if ( foreign_key_exists( 'reserves', 'reserves_ibfk_ig' ) ) {
$dbh->do(
q|
ALTER TABLE reserves
DROP FOREIGN KEY reserves_ibfk_ig
|
);
$dbh->do(
q|
ALTER TABLE reserves
ADD CONSTRAINT reserves_ibfk_ig
FOREIGN KEY (item_group_id)
REFERENCES item_groups (item_group_id) ON DELETE SET NULL ON UPDATE CASCADE
|
);
}
say $out "FK 'reserves_ibfk_ig' on reserves updated to ON DELETE SET NULL";
},
};