From 012e5bff1c79d8a2cc580a43c832ace5e51bec79 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 3 Nov 2021 16:51:09 +0000 Subject: [PATCH] Bug 29409: Check for existence of constraint before deletion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Joonas Kylmälä Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/updatedatabase.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 811b7ee632..8a02ead757 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -23186,10 +23186,11 @@ $DBversion = '20.06.00.058'; if( CheckVersion( $DBversion ) ) { # Adding the ON DELETE CASCASE ON UPDATE CASCADE, in case it's missing (from 9016 - 3.15.00.039) - $dbh->do( q{ - ALTER TABLE letter DROP FOREIGN KEY message_transport_type_fk - } ); - + if ( foreign_key_exists( 'letter', 'message_transport_type_fk' ) ) { + $dbh->do( q{ + ALTER TABLE letter DROP FOREIGN KEY message_transport_type_fk + } ); + } $dbh->do( q{ ALTER TABLE letter ADD CONSTRAINT message_transport_type_fk FOREIGN KEY (message_transport_type) REFERENCES message_transport_types(message_transport_type) ON DELETE CASCADE ON UPDATE CASCADE } ); -- 2.39.5