mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
35 lines
832 B
Go
35 lines
832 B
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect"
|
|
"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"`).Immutable(),
|
|
field.String("value").SchemaType(map[string]string{
|
|
dialect.MySQL: "longtext",
|
|
dialect.Postgres: "text",
|
|
}).StructTag(`json:"value"`), // a json object
|
|
}
|
|
}
|
|
|
|
func (ConfigItem) Edges() []ent.Edge {
|
|
return nil
|
|
}
|