[Koha-patches] [PATCH] Bug 4972 Fix table creations failing due to foreign key checks
Colin Campbell
colin.campbell at ptfs-europe.com
Thu Jul 8 17:19:17 CEST 2010
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
---
installer/data/mysql/updatedatabase.pl | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 68e7cbc..53edfbf 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);
}
--
1.7.1
More information about the Koha-patches
mailing list