From c4427c194b72802e361c1626657922bd746bccdc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 23 Oct 2015 14:20:17 +0100 Subject: [PATCH] Bug 10363: Fix Updatedb entry on MariaDB With MariaDB, I get the following error: ERROR 1832 (HY000): Cannot change column 'av_id': used in a foreign key constraint 'authorised_values_branches_ibfk_1' The solution would be to remove the constraints, modify the columns and finally reintroduce the foreign keys. Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/updatedatabase.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index fd034ab89e..f5b35a848b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -11099,9 +11099,16 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.21.00.036"; if ( CheckVersion($DBversion) ) { $dbh->do(q{ - ALTER TABLE authorised_values_branches - CHANGE av_id av_id INT( 11 ) NOT NULL, - CHANGE branchcode branchcode VARCHAR( 10 ) NOT NULL + ALTER TABLE authorised_values_branches + DROP FOREIGN KEY authorised_values_branches_ibfk_1, + DROP FOREIGN KEY authorised_values_branches_ibfk_2 + }); + $dbh->do(q{ + ALTER TABLE authorised_values_branches + MODIFY av_id INT( 11 ) NOT NULL, + MODIFY branchcode VARCHAR( 10 ) NOT NULL, + ADD FOREIGN KEY (`av_id`) REFERENCES `authorised_values` (`id`) ON DELETE CASCADE, + ADD FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE }); print "Upgrade to $DBversion done (Bug 10363: There is no package for authorised values)\n"; SetVersion($DBversion); -- 2.39.5