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

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

parent ac44d2f1
...@@ -140,40 +140,22 @@ try { ...@@ -140,40 +140,22 @@ try {
); );
} }
//engine postpone //engine postpone
$statement = $pearDB->query( if (!$pearDB->isColumnExist('cfg_nagios', 'postpone_notification_to_timeperiod')) {
'SELECT COLUMN_DEFAULT // An update is required
FROM information_schema.COLUMNS $errorMessage = 'Impossible to alter the table cfg_nagios with postpone_notification_to_timeperiod';
WHERE TABLE_NAME = \'cfg_nagios\' $pearDB->query(
AND COLUMN_NAME = \'postpone_notification_to_timeperiod\'' 'ALTER TABLE `cfg_nagios` ADD COLUMN
);
if (($result = $statement->fetch(\PDO::FETCH_ASSOC)) !== false) {
$defaultValue = $result['COLUMN_DEFAULT'];
if ($defaultValue !== '0') {
// An update is required
$errorMessage = 'Impossible to alter the table cfg_nagios with postpone_notification_to_timeperiod';
$pearDB->query(
'ALTER TABLE `cfg_nagios` ADD COLUMN
`postpone_notification_to_timeperiod` boolean DEFAULT false AFTER `nagios_group`' `postpone_notification_to_timeperiod` boolean DEFAULT false AFTER `nagios_group`'
); );
}
} }
//engine heartbeat interval //engine heartbeat interval
$statement = $pearDB->query( if (!$pearDB->isColumnExist('cfg_nagios', 'instance_heartbeat_interval')) {
'SELECT COLUMN_DEFAULT // An update is required
FROM information_schema.COLUMNS $errorMessage = 'Impossible to alter the table cfg_nagios with instance_heartbeat_interval';
WHERE TABLE_NAME = \'cfg_nagios\' $pearDB->query(
AND COLUMN_NAME = \'instance_heartbeat_interval\'' 'ALTER TABLE `cfg_nagios` ADD COLUMN
); `instance_heartbeat_interval` smallint DEFAULT 30 AFTER `date_format`'
if (($result = $statement->fetch(\PDO::FETCH_ASSOC)) !== false) { );
$defaultValue = $result['COLUMN_DEFAULT'];
if ($defaultValue !== '0') {
// 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`'
);
}
} }
$errorMessage = ""; $errorMessage = "";
} catch (\Exception $e) { } catch (\Exception $e) {
......
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