From 016ebfe0affc86e14115afe34d415bc58f9164b3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Apr 2017 14:47:44 +0200 Subject: [statistics] Better errormsg in install, link to projectors added --- modules-available/statistics/install.inc.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'modules-available/statistics/install.inc.php') diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index 5d8ce1bc..79346f99 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -201,16 +201,21 @@ if ($addTrigger) { } if ($machineHwCreate === UPDATE_DONE) { - $ret = true; $ret = Database::exec('ALTER TABLE `machine_x_hw` ADD CONSTRAINT `machine_x_hw_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE, - ADD CONSTRAINT `machine_x_hw_ibfk_2` FOREIGN KEY (`machineuuid`) REFERENCES `machine` (`machineuuid`) ON DELETE CASCADE') && $ret; + ADD CONSTRAINT `machine_x_hw_ibfk_2` FOREIGN KEY (`machineuuid`) REFERENCES `machine` (`machineuuid`) ON DELETE CASCADE'); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding constraints to machine_x_hw failed: ' . Database::lastError()); + } $ret = Database::exec('ALTER TABLE `machine_x_hw_prop` - ADD CONSTRAINT `machine_x_hw_prop_ibfk_1` FOREIGN KEY (`machinehwid`) REFERENCES `machine_x_hw` (`machinehwid`) ON DELETE CASCADE') && $ret; + ADD CONSTRAINT `machine_x_hw_prop_ibfk_1` FOREIGN KEY (`machinehwid`) REFERENCES `machine_x_hw` (`machinehwid`) ON DELETE CASCADE'); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding constraint to machine_x_hw_prop failed: ' . Database::lastError()); + } $ret = Database::exec('ALTER TABLE `statistic_hw_prop` - ADD CONSTRAINT `statistic_hw_prop_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE') && $ret; + ADD CONSTRAINT `statistic_hw_prop_ibfk_1` FOREIGN KEY (`hwid`) REFERENCES `statistic_hw` (`hwid`) ON DELETE CASCADE'); if ($ret === false) { - finalResponse(UPDATE_FAILED, 'Adding foreign key machineuuid to hardware* failed: ' . Database::lastError()); + finalResponse(UPDATE_FAILED, 'Adding constraint to statistic_hw_prop failed: ' . Database::lastError()); } } -- cgit v1.2.3-55-g7522