41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
|
package schema
|
||
|
|
||
|
import (
|
||
|
"entgo.io/ent"
|
||
|
"entgo.io/ent/schema/edge"
|
||
|
"entgo.io/ent/schema/field"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// Mailbox holds the schema definition for the Mailbox entity.
|
||
|
type Mailbox struct {
|
||
|
ent.Schema
|
||
|
}
|
||
|
|
||
|
// Fields of the Mailbox.
|
||
|
func (Mailbox) Fields() []ent.Field {
|
||
|
return []ent.Field{
|
||
|
field.Int64("id"),
|
||
|
field.Bool("active"),
|
||
|
field.Time("created").Default(time.Now).Immutable(),
|
||
|
field.Time("modified").Default(time.Now).UpdateDefault(time.Now).Nillable().Optional(),
|
||
|
field.Int64("domain_id").Optional(),
|
||
|
field.String("username"),
|
||
|
field.Bytes("password"),
|
||
|
field.String("name").Nillable().Optional(),
|
||
|
field.Int64("quota"),
|
||
|
field.String("local_part"),
|
||
|
field.String("homedir").Nillable().Optional(),
|
||
|
field.String("maildir").Nillable().Optional(),
|
||
|
field.Int32("uid").Nillable().Optional(),
|
||
|
field.Int32("gid").Nillable().Optional(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Edges of the Mailbox.
|
||
|
func (Mailbox) Edges() []ent.Edge {
|
||
|
return []ent.Edge{
|
||
|
edge.From("domain", Domain.Type).Ref("mailboxes").Field("domain_id").Unique(),
|
||
|
}
|
||
|
}
|