Documentation
¶
Overview ¶
Package model holds the audit log's entity.
Index ¶
Constants ¶
const SystemActor = "system"
SystemActor is recorded for a change made with no caller behind it, such as the execution engine moving a process to its next status.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
// OccurredAt is when the change was made, in milliseconds since the epoch.
OccurredAt int64 `` /* 168-byte string literal not displayed */
// Actor is the principal's name — a users.user_id, "root", or "sa:<name>" — or
// SystemActor.
Actor string `gorm:"column:actor;type:varchar(255);not null;index:idx_audit_events_actor,priority:1" json:"actor"`
Action Action `gorm:"column:action;type:varchar(10);not null" json:"action"`
// EntityType is the table the record lives in, such as "processes", and EntityID its
// primary key; a composite key is joined with ":". EntityID is empty when the
// change addressed rows by a condition instead of by key.
EntityType string `gorm:"column:entity_type;type:varchar(64);not null;index:idx_audit_events_entity,priority:1" json:"entityType"`
EntityID string `gorm:"column:entity_id;type:varchar(255);not null;default:'';index:idx_audit_events_entity,priority:2" json:"entityId"`
// ChangedFields lists the columns an update named, comma-separated, when the write
// named them. Empty for a create, a delete, and an update that saved the whole record.
ChangedFields string `gorm:"column:changed_fields;type:varchar(1024);not null;default:''" json:"changedFields"`
}
Event is one change to one record: who made it, what was done and to what.
The table is append-only. Nothing in the server updates or deletes a row, and it deliberately has no foreign keys: an audit trail must outlive the users and records it describes, so Actor and EntityID are plain strings rather than references.
An event names the record, never its contents. Values are left out on purpose: rows carry token digests, SSH passwords and job secrets, and a log that copied them would be a second place to protect them.