bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/database/ent/schema/alert.go (about) 1 package schema 2 3 import ( 4 "time" 5 6 "entgo.io/ent" 7 "entgo.io/ent/schema/edge" 8 "entgo.io/ent/schema/field" 9 ) 10 11 // Alert holds the schema definition for the Alert entity. 12 type Alert struct { 13 ent.Schema 14 } 15 16 // Fields of the Alert. 17 func (Alert) Fields() []ent.Field { 18 return []ent.Field{ 19 field.Time("created_at"). 20 Default(time.Now), 21 field.Time("updated_at"). 22 Default(time.Now), 23 field.String("scenario"), 24 field.String("bucketId").Default("").Optional(), 25 field.String("message").Default("").Optional(), 26 field.Int32("eventsCount").Default(0).Optional(), 27 field.Time("startedAt").Default(time.Now).Optional(), 28 field.Time("stoppedAt").Default(time.Now).Optional(), 29 field.String("sourceIp"). 30 Optional(), 31 field.String("sourceRange"). 32 Optional(), 33 field.String("sourceAsNumber"). 34 Optional(), 35 field.String("sourceAsName"). 36 Optional(), 37 field.String("sourceCountry"). 38 Optional(), 39 field.Float32("sourceLatitude"). 40 Optional(), 41 field.Float32("sourceLongitude"). 42 Optional(), 43 field.String("sourceScope").Optional(), 44 field.String("sourceValue").Optional(), 45 field.Int32("capacity").Optional(), 46 field.String("leakSpeed").Optional(), 47 field.String("scenarioVersion").Optional(), 48 field.String("scenarioHash").Optional(), 49 field.Bool("simulated").Default(false), 50 } 51 } 52 53 // Edges of the Alert. 54 func (Alert) Edges() []ent.Edge { 55 return []ent.Edge{ 56 edge.From("owner", Machine.Type). 57 Ref("alerts"). 58 Unique(), 59 edge.To("decisions", Decision.Type), 60 edge.To("events", Event.Type), 61 edge.To("metas", Meta.Type), 62 } 63 }