@@ -, +, @@ alter table old_reserves ADD CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE; --- installer/data/mysql/atomicupdate/bug_30497.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_30497.pl --- a/installer/data/mysql/atomicupdate/bug_30497.pl +++ a/installer/data/mysql/atomicupdate/bug_30497.pl @@ -0,0 +1,16 @@ +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 CONSTRAINT old_reserves_ibfk_4| ); + $dbh->do( q|ALTER TABLE old_reserves ADD CONSTRAINT old_reserves_ibfk_4 FOREIGN KEY (itemtype) REFERENCES itemtypes (itemtype) ON DELETE SET NULL ON UPDATE SET NULL| ); + } + }, +}; --