Commit 1d84207f authored by loiclau's avatar loiclau Committed by Loic Laurent
Browse files

fix(update) fix check column existence (#9466)

parent ac44d2f1
......@@ -140,15 +140,7 @@ try {
);
}
//engine postpone
$statement = $pearDB->query(
'SELECT COLUMN_DEFAULT
FROM information_schema.COLUMNS
WHERE TABLE_NAME = \'cfg_nagios\'
AND COLUMN_NAME = \'postpone_notification_to_timeperiod\''
);
if (($result = $statement->fetch(\PDO::FETCH_ASSOC)) !== false) {
$defaultValue = $result['COLUMN_DEFAULT'];
if ($defaultValue !== '0') {
if (!$pearDB->isColumnExist('cfg_nagios', 'postpone_notification_to_timeperiod')) {
// An update is required
$errorMessage = 'Impossible to alter the table cfg_nagios with postpone_notification_to_timeperiod';
$pearDB->query(
......@@ -156,25 +148,15 @@ try {
`postpone_notification_to_timeperiod` boolean DEFAULT false AFTER `nagios_group`'
);
}
}
//engine heartbeat interval
$statement = $pearDB->query(
'SELECT COLUMN_DEFAULT
FROM information_schema.COLUMNS
WHERE TABLE_NAME = \'cfg_nagios\'
AND COLUMN_NAME = \'instance_heartbeat_interval\''
);
if (($result = $statement->fetch(\PDO::FETCH_ASSOC)) !== false) {
$defaultValue = $result['COLUMN_DEFAULT'];
if ($defaultValue !== '0') {
if (!$pearDB->isColumnExist('cfg_nagios', 'instance_heartbeat_interval')) {
// An update is required
$errorMessage = 'Impossible to alter the table cfg_nagios with instance_heartbeat_interval';
$pearDB->query(
'ALTER TABLE `cfg_nagios` ADD COLUMN
`instance_heartbeat_interval` smallint DEFAULT 30 false AFTER `date_format`'
`instance_heartbeat_interval` smallint DEFAULT 30 AFTER `date_format`'
);
}
}
$errorMessage = "";
} catch (\Exception $e) {
$centreonLog->insertLog(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment