github.com/crowdsecurity/crowdsec@v1.6.1/pkg/database/ent/schema/machine.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 "github.com/crowdsecurity/crowdsec/pkg/types" 8 ) 9 10 // Machine holds the schema definition for the Machine entity. 11 type Machine struct { 12 ent.Schema 13 } 14 15 // Fields of the Machine. 16 func (Machine) Fields() []ent.Field { 17 return []ent.Field{ 18 field.Time("created_at"). 19 Default(types.UtcNow). 20 UpdateDefault(types.UtcNow).Nillable().Optional(), 21 field.Time("updated_at"). 22 Default(types.UtcNow). 23 UpdateDefault(types.UtcNow).Nillable().Optional(), 24 field.Time("last_push"). 25 Default(types.UtcNow). 26 UpdateDefault(types.UtcNow).Nillable().Optional(), 27 field.Time("last_heartbeat"). 28 Default(types.UtcNow). 29 UpdateDefault(types.UtcNow).Nillable().Optional(), 30 field.String("machineId").Unique(), 31 field.String("password").Sensitive(), 32 field.String("ipAddress"), 33 field.String("scenarios").MaxLen(100000).Optional(), 34 field.String("version").Optional(), 35 field.Bool("isValidated"). 36 Default(false), 37 field.String("status").Optional(), 38 field.String("auth_type").Default(types.PasswordAuthType).StructTag(`json:"auth_type"`), 39 } 40 } 41 42 // Edges of the Machine. 43 func (Machine) Edges() []ent.Edge { 44 return []ent.Edge{ 45 edge.To("alerts", Alert.Type), 46 } 47 }