From d903d05c8239fd15cd48b81590c1b95d4d3a69a3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 26 Oct 2021 17:52:39 +0200 Subject: [PATCH] Make History*#Id UUID -> SHA1 --- pkg/icingadb/v1/history/meta.go | 4 ++-- schema/mysql/schema.sql | 2 +- schema/mysql/upgrades/1.0.0-rc2.sql | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/icingadb/v1/history/meta.go b/pkg/icingadb/v1/history/meta.go index bb9aad2f..434ed118 100644 --- a/pkg/icingadb/v1/history/meta.go +++ b/pkg/icingadb/v1/history/meta.go @@ -25,7 +25,7 @@ func (hte HistoryTableEntity) Upsert() interface{} { // HistoryEntity is embedded by every concrete history type. type HistoryEntity struct { - Id types.UUID `json:"event_id"` + Id types.Binary `json:"event_id"` } // Fingerprint implements part of the contracts.Entity interface. @@ -40,7 +40,7 @@ func (he HistoryEntity) ID() contracts.ID { // SetID implements part of the contracts.Entity interface. func (he *HistoryEntity) SetID(id contracts.ID) { - he.Id = id.(types.UUID) + he.Id = id.(types.Binary) } // Upsert implements the contracts.Upserter interface. diff --git a/schema/mysql/schema.sql b/schema/mysql/schema.sql index 18f9cb3d..faae4e02 100644 --- a/schema/mysql/schema.sql +++ b/schema/mysql/schema.sql @@ -1061,7 +1061,7 @@ CREATE TABLE acknowledgement_history ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; CREATE TABLE history ( - id binary(16) NOT NULL COMMENT 'notification_history_id, state_history_id or UUID', + id binary(20) NOT NULL COMMENT 'sha1(environment.name + event_type + x...) given that sha1(environment.name + x...) = *_history_id', environment_id binary(20) NOT NULL COMMENT 'environment.id', endpoint_id binary(20) DEFAULT NULL COMMENT 'endpoint.id', object_type enum('host', 'service') NOT NULL, diff --git a/schema/mysql/upgrades/1.0.0-rc2.sql b/schema/mysql/upgrades/1.0.0-rc2.sql index 6c3ff620..43a7e663 100644 --- a/schema/mysql/upgrades/1.0.0-rc2.sql +++ b/schema/mysql/upgrades/1.0.0-rc2.sql @@ -182,6 +182,7 @@ ALTER TABLE user_notification_history MODIFY notification_history_id binary(20) NOT NULL COMMENT 'UUID notification_history.id'; ALTER TABLE history + MODIFY id binary(20) NOT NULL COMMENT 'sha1(environment.name + event_type + x...) given that sha1(environment.name + x...) = *_history_id', MODIFY notification_history_id binary(20) DEFAULT NULL COMMENT 'notification_history.id', MODIFY state_history_id binary(20) DEFAULT NULL COMMENT 'state_history.id', ADD CONSTRAINT fk_history_acknowledgement_history FOREIGN KEY (acknowledgement_history_id) REFERENCES acknowledgement_history (id) ON DELETE CASCADE,