From ec37898312831d435cbbcdbc5c0dff5837e966c8 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. --- 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 3360de6..6e9c1ae 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -11098,9 +11098,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.1.0