crowdsec/pkg/database/ent/schema/config.go
mmetc 91fbc63533
db: review update timestamps, immutable columns (#2981)
* orm: correct behavior of created_at, updated_at, define immutable fields

* remove updatedefault for last_push, last_heartbeat

* re-generate db schema

* update last_push in CreateAlert()

* lint
2024-05-02 12:56:41 +02:00

30 lines
698 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
// ConfigItem holds the schema definition for the ConfigItem entity.
type ConfigItem struct {
ent.Schema
}
func (ConfigItem) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow).
Immutable().
StructTag(`json:"created_at"`),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).StructTag(`json:"updated_at"`),
field.String("name").Unique().StructTag(`json:"name"`),
field.String("value").StructTag(`json:"value"`), // a json object
}
}
func (ConfigItem) Edges() []ent.Edge {
return nil
}