From a0065707d88d8e89a0480795eae7ef5d7581671a Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 8 Jul 2010 16:19:17 +0100 Subject: [PATCH] Bug 4972 Fix table creations failing due to foreign key checks create tables were failing with cryptic 1005 error from mysql wrapped creation of aqbasketgroups and aqcontract in FOREIGN_KEY_CHECKS=0 and FOREIGN_KEY_CHECKS=1 Signed-off-by: Galen Charlton --- installer/data/mysql/updatedatabase.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 11f6c5a826..f4bd0a5c76 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -2818,6 +2818,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = '3.01.00.073'; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do('SET FOREIGN_KEY_CHECKS=0 '); $dbh->do(<<'END_SQL'); CREATE TABLE IF NOT EXISTS `aqcontract` ( `contractnumber` int(11) NOT NULL auto_increment, @@ -2831,6 +2832,7 @@ CREATE TABLE IF NOT EXISTS `aqcontract` ( REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; END_SQL + $dbh->do('SET FOREIGN_KEY_CHECKS=1 '); print "Upgrade to $DBversion done (adding aqcontract table)\n"; SetVersion ($DBversion); } @@ -2856,6 +2858,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $DBversion = '3.01.00.076'; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do('SET FOREIGN_KEY_CHECKS=0 '); $dbh->do("CREATE TABLE IF NOT EXISTS `aqbasketgroups` ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) default NULL, @@ -2868,6 +2871,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("ALTER TABLE aqbasket ADD COLUMN `basketgroupid` int(11)"); $dbh->do("ALTER TABLE aqbasket ADD FOREIGN KEY (`basketgroupid`) REFERENCES `aqbasketgroups` (`id`) ON UPDATE CASCADE ON DELETE SET NULL"); $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('pdfformat','pdfformat::layout2pages','Controls what script is used for printing (basketgroups)','','free')"); + $dbh->do('SET FOREIGN_KEY_CHECKS=1 '); print "Upgrade to $DBversion done (adding basketgroups)\n"; SetVersion ($DBversion); } -- 2.39.5