From 14b9274135f32c92c655fc070eb912c4f39b4eca Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 8 Apr 2022 08:23:56 +0000 Subject: [PATCH] Bug 30497: Recreate old_reserves_ibfk_4 when it cascades Test plan: Drop old_reserves_ibfk_4. Add back with: alter table old_reserves ADD CONSTRAINT `old_reserves_ibfk_4` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE; Run dbrev. Check that constraint has been replaced by SET NULL. Run dbrev again. No changes. Signed-off-by: Marcel de Rooy [EDIT 23-08-22 Replaced DROP CONSTRAINT] Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/bug_30497.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_30497.pl diff --git a/installer/data/mysql/atomicupdate/bug_30497.pl b/installer/data/mysql/atomicupdate/bug_30497.pl new file mode 100755 index 0000000000..01df5ace1b --- /dev/null +++ b/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 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| ); + } + }, +}; -- 2.39.5