mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
Add support for specifying schema types for the `value` field in the `ConfigItem` schema. This includes defining `longtext` for MySQL and `text` for PostgreSQL, enhancing text capacity for this field
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
|
|
}
|