mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-14 13:24:34 +02:00
46 lines
913 B
Go
46 lines
913 B
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
|
)
|
|
|
|
// Event holds the schema definition for the Event entity.
|
|
type Event struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the Event.
|
|
func (Event) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Time("created_at").
|
|
Default(types.UtcNow).
|
|
Immutable(),
|
|
field.Time("updated_at").
|
|
Default(types.UtcNow).
|
|
UpdateDefault(types.UtcNow),
|
|
field.Time("time").Immutable(),
|
|
field.String("serialized").MaxLen(8191).Immutable(),
|
|
field.Int("alert_events").Optional(),
|
|
}
|
|
}
|
|
|
|
// Edges of the Event.
|
|
func (Event) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("owner", Alert.Type).
|
|
Ref("events").
|
|
Field("alert_events").
|
|
Unique(),
|
|
}
|
|
}
|
|
|
|
func (Event) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("alert_events"),
|
|
}
|
|
}
|