34 lines
794 B
Go
34 lines
794 B
Go
|
package schema
|
||
|
|
||
|
import (
|
||
|
"entgo.io/ent"
|
||
|
"entgo.io/ent/dialect/entsql"
|
||
|
"entgo.io/ent/schema/edge"
|
||
|
"entgo.io/ent/schema/field"
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
// Email holds the schema definition for the Email entity.
|
||
|
type Email struct {
|
||
|
ent.Schema
|
||
|
}
|
||
|
|
||
|
// Fields of the Email.
|
||
|
func (Email) Fields() []ent.Field {
|
||
|
return []ent.Field{
|
||
|
field.UUID("id", uuid.UUID{}).Unique().Immutable().Annotations(&entsql.Annotation{Default: "gen_random_uuid()"}),
|
||
|
field.String("email"),
|
||
|
field.Bool("primary").Default(false),
|
||
|
field.Bool("verified").Default(false),
|
||
|
field.String("verification_code").Optional(),
|
||
|
field.String("reset_code").Optional(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Edges of the Email.
|
||
|
func (Email) Edges() []ent.Edge {
|
||
|
return []ent.Edge{
|
||
|
edge.From("accounts", Account.Type).Ref("emails").Unique(),
|
||
|
}
|
||
|
}
|