manager/ent/schema/logentry.go

34 lines
775 B
Go
Raw Normal View History

2022-04-08 21:23:41 +02:00
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// Logentry holds the schema definition for the Logentry entity.
type Logentry struct {
ent.Schema
}
// Fields of the Logentry.
func (Logentry) Fields() []ent.Field {
return []ent.Field{
field.Int64("id"),
field.Time("timestamp").Default(time.Now).Immutable(),
field.String("action"),
field.Text("data").Optional().Nillable(),
2022-04-08 21:25:46 +02:00
field.Int64("account_id").Optional(),
field.Int64("domain_id").Optional(),
2022-04-08 21:23:41 +02:00
}
}
// Edges of the Logentry.
func (Logentry) Edges() []ent.Edge {
return []ent.Edge{
edge.From("account", Account.Type).Ref("logs").Field("account_id").Unique(),
edge.From("domain", Domain.Type).Ref("logs").Field("domain_id").Unique(),
}
}