mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-14 13:24:34 +02:00
45 lines
893 B
Go
45 lines
893 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"
|
|
)
|
|
|
|
// Meta holds the schema definition for the Meta entity.
|
|
type Meta struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the Meta.
|
|
func (Meta) 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.String("key").Immutable(),
|
|
field.String("value").MaxLen(4095).Immutable(),
|
|
field.Int("alert_metas").Optional(),
|
|
}
|
|
}
|
|
|
|
// Edges of the Meta.
|
|
func (Meta) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.From("owner", Alert.Type).
|
|
Ref("metas").
|
|
Field("alert_metas").
|
|
Unique(),
|
|
}
|
|
}
|
|
|
|
func (Meta) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("alert_metas"),
|
|
}
|
|
}
|