From 2ec0743568e9a36e643e63471d40f1ae0befc117 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 5 Oct 2022 09:49:07 +0200 Subject: [PATCH] fixed issue with negative notification_numbers during update (#11936) Co-authored-by: dmyios Refs: MON-15318 --- www/install/php/Update-22.04.6.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/install/php/Update-22.04.6.php b/www/install/php/Update-22.04.6.php index 932a8d14d06..a96fd9372f1 100644 --- a/www/install/php/Update-22.04.6.php +++ b/www/install/php/Update-22.04.6.php @@ -29,14 +29,22 @@ try { $errorMessage = "Impossible to update 'hosts' table"; if (! str_contains(strtolower($pearDBO->getColumnType('hosts', 'notification_number')), 'bigint')) { + $pearDBO->beginTransaction(); + $pearDBO->query("UPDATE `hosts` SET `notification_number`= 0 WHERE `notification_number`< 0"); $pearDBO->query("ALTER TABLE `hosts` MODIFY `notification_number` BIGINT(20) UNSIGNED DEFAULT NULL"); } $errorMessage = "Impossible to update 'services' table"; if (! str_contains(strtolower($pearDBO->getColumnType('services', 'notification_number')), 'bigint')) { + $pearDBO->beginTransaction(); + $pearDBO->query("UPDATE `services` SET `notification_number`= 0 WHERE `notification_number`< 0"); $pearDBO->query("ALTER TABLE `services` MODIFY `notification_number` BIGINT(20) UNSIGNED DEFAULT NULL"); } } catch (\Exception $e) { + if ($pearDBO->inTransaction()) { + $pearDBO->rollBack(); + } + $centreonLog->insertLog( 4, $versionOfTheUpgrade . $errorMessage .