Koha/installer/data/mysql/db_revs/220600050.pl
Tomas Cohen Arazi 734c8fe70e
Bug 30497: DBRev 22.06.00.050
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-09-22 08:38:10 -03:00

16 lines
642 B
Perl
Executable file

use Modern::Perl;
return {
bug_number => 30497,
description => "Recreate old_reserves_ibfk_4 if cascading",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
my @info = $dbh->selectrow_array( q|SHOW CREATE TABLE old_reserves| );
if( $info[1] =~ /^\s*CONSTRAINT .old_reserves_ibfk_4.*CASCADE$/m ) {
$dbh->do( q|ALTER TABLE old_reserves DROP FOREIGN KEY old_reserves_ibfk_4| );
$dbh->do( q|ALTER TABLE old_reserves ADD FOREIGN KEY old_reserves_ibfk_4 (itemtype) REFERENCES itemtypes (itemtype) ON DELETE SET NULL ON UPDATE SET NULL| );
}
},
};