Make History*#Id UUID -> SHA1

This commit is contained in:
Alexander A. Klimov 2021-10-26 17:52:39 +02:00
parent 52ae34a6f8
commit d903d05c82
3 changed files with 4 additions and 3 deletions

View file

@ -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.

View file

@ -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,

View file

@ -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,