github.com/crowdsecurity/crowdsec@v1.6.1/pkg/database/ent/schema/meta.go (about) 1 package schema 2 3 import ( 4 "entgo.io/ent" 5 "entgo.io/ent/schema/edge" 6 "entgo.io/ent/schema/field" 7 "entgo.io/ent/schema/index" 8 "github.com/crowdsecurity/crowdsec/pkg/types" 9 ) 10 11 // Meta holds the schema definition for the Meta entity. 12 type Meta struct { 13 ent.Schema 14 } 15 16 // Fields of the Meta. 17 func (Meta) Fields() []ent.Field { 18 return []ent.Field{ 19 field.Time("created_at"). 20 Default(types.UtcNow). 21 UpdateDefault(types.UtcNow).Nillable().Optional(), 22 field.Time("updated_at"). 23 Default(types.UtcNow). 24 UpdateDefault(types.UtcNow).Nillable().Optional(), 25 field.String("key"), 26 field.String("value").MaxLen(4095), 27 field.Int("alert_metas").Optional(), 28 } 29 } 30 31 // Edges of the Meta. 32 func (Meta) Edges() []ent.Edge { 33 return []ent.Edge{ 34 edge.From("owner", Alert.Type). 35 Ref("metas"). 36 Field("alert_metas"). 37 Unique(), 38 } 39 } 40 41 func (Meta) Indexes() []ent.Index { 42 return []ent.Index{ 43 index.Fields("alert_metas"), 44 } 45 }