From 1e24a60ff866edbe5a697ed441285ef53f25347b Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Mon, 9 Dec 2019 10:29:16 +0100 Subject: [PATCH] History: Add cancelled_by & removed_by to downtime & comment history --- configobject/history/history.go | 10 ++++++---- etc/schema/mysql/mysql.schema.sql | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configobject/history/history.go b/configobject/history/history.go index 98f80edc..a1ba3af4 100644 --- a/configobject/history/history.go +++ b/configobject/history/history.go @@ -243,8 +243,8 @@ func stateHistoryWorker(super *supervisor.Supervisor) { func downtimeHistoryWorker(super *supervisor.Supervisor) { statements := []string{ `REPLACE INTO downtime_history (downtime_id, environment_id, endpoint_id, triggered_by_id, object_type, host_id, service_id, entry_time,` + - `author, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, start_time, end_time, has_been_cancelled, trigger_time, cancel_time)` + - `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, + `author, cancelled_by, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, start_time, end_time, has_been_cancelled, trigger_time, cancel_time)` + + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, `REPLACE INTO history (id, environment_id, endpoint_id, object_type, host_id, service_id, notification_history_id,` + `state_history_id, downtime_history_id, comment_history_id, flapping_history_id, event_type, event_time)` + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)`, @@ -267,6 +267,7 @@ func downtimeHistoryWorker(super *supervisor.Supervisor) { utils.DecodeHexIfNotNil(values["service_id"]), values["entry_time"], values["author"], + values["cancelled_by"], values["comment"], utils.RedisIntToDBBoolean(values["is_flexible"]), values["flexible_duration"], @@ -319,8 +320,8 @@ func downtimeHistoryWorker(super *supervisor.Supervisor) { func commentHistoryWorker(super *supervisor.Supervisor) { statements := []string{ `REPLACE INTO comment_history (comment_id, environment_id, endpoint_id, object_type, host_id, service_id, entry_time, author,` + - `comment, entry_type, is_persistent, is_sticky, expire_time, remove_time, has_been_removed)` + - `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, + `removed_by, comment, entry_type, is_persistent, is_sticky, expire_time, remove_time, has_been_removed)` + + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, `REPLACE INTO history (id, environment_id, endpoint_id, object_type, host_id, service_id, notification_history_id,` + `state_history_id, downtime_history_id, comment_history_id, flapping_history_id, event_type, event_time)` + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)`, @@ -337,6 +338,7 @@ func commentHistoryWorker(super *supervisor.Supervisor) { utils.DecodeHexIfNotNil(values["service_id"]), values["entry_time"], values["author"], + values["removed_by"], values["comment"], utils.CommentEntryTypes[values["entry_type"].(string)], utils.RedisIntToDBBoolean(values["is_persistent"]), diff --git a/etc/schema/mysql/mysql.schema.sql b/etc/schema/mysql/mysql.schema.sql index cb7cb629..4345133e 100644 --- a/etc/schema/mysql/mysql.schema.sql +++ b/etc/schema/mysql/mysql.schema.sql @@ -874,6 +874,7 @@ CREATE TABLE downtime_history ( entry_time bigint(20) unsigned NOT NULL, author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci, + cancelled_by varchar(255) NULL DEFAULT NULL COLLATE utf8mb4_unicode_ci, comment text NOT NULL, is_flexible enum('y', 'n') NOT NULL, flexible_duration bigint(20) unsigned NOT NULL, @@ -898,6 +899,7 @@ CREATE TABLE comment_history ( entry_time bigint(20) unsigned NOT NULL, author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci, + removed_by varchar(255) NULL DEFAULT NULL COLLATE utf8mb4_unicode_ci, comment text NOT NULL, entry_type enum('comment','ack') NOT NULL, is_persistent enum('y','n') NOT NULL,