From 7c0c2939cbc0f13b27aca7524842edb4504440ef Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Wed, 27 Mar 2024 02:35:39 +0100 Subject: [PATCH] Bug 35610: (QA follow-up): tidy up code Signed-off-by: Katrin Fischer --- installer/data/mysql/atomicupdate/bug_35610.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_35610.pl b/installer/data/mysql/atomicupdate/bug_35610.pl index 6143bd9e11..753adce25e 100755 --- a/installer/data/mysql/atomicupdate/bug_35610.pl +++ b/installer/data/mysql/atomicupdate/bug_35610.pl @@ -7,18 +7,22 @@ return { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; - unless ( foreign_key_exists('old_reserves', 'old_reserves_ibfk_branchcode') ) { - $dbh->do(q{ + unless ( foreign_key_exists( 'old_reserves', 'old_reserves_ibfk_branchcode' ) ) { + $dbh->do( + q{ UPDATE old_reserves SET branchcode = NULL WHERE branchcode NOT IN (SELECT branchcode FROM branches) - }); + } + ); - $dbh->do(q{ + $dbh->do( + q{ ALTER TABLE old_reserves ADD CONSTRAINT `old_reserves_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE; - }); - say $out "Added foreign key on 'old_reserves.branchcode'" + } + ); + say $out "Added foreign key on 'old_reserves.branchcode'"; } }, }; -- 2.39.5