crowdsec/pkg/database/ent/schema/machine.go
Thibault "bui" Koechlin cc1ab8c50d
switch to utc time everywhere (#1167)
* switch to utc time everywhere


Co-authored-by: alteredCoder <kevin@crowdsec.net>
2022-01-19 14:56:05 +01:00

44 lines
1 KiB
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
// Machine holds the schema definition for the Machine entity.
type Machine struct {
ent.Schema
}
// Fields of the Machine.
func (Machine) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.Time("last_push").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.String("machineId").Unique(),
field.String("password").Sensitive(),
field.String("ipAddress"),
field.String("scenarios").MaxLen(4095).Optional(),
field.String("version").Optional(),
field.Bool("isValidated").
Default(false),
field.String("status").Optional(),
}
}
// Edges of the Machine.
func (Machine) Edges() []ent.Edge {
return []ent.Edge{
edge.To("alerts", Alert.Type),
}
}