feat(schema): restore complete Ent schema files
This commit is contained in:
57
internal/ent/schema/user.go
Normal file
57
internal/ent/schema/user.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// User holds the schema definition for the User entity.
|
||||
type User struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the User.
|
||||
func (User) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("id").
|
||||
Unique().
|
||||
Immutable(),
|
||||
field.String("email").
|
||||
Unique().
|
||||
NotEmpty(),
|
||||
field.String("username").
|
||||
Optional(),
|
||||
field.String("first_name").
|
||||
Optional(),
|
||||
field.String("last_name").
|
||||
Optional(),
|
||||
field.String("password_hash").
|
||||
NotEmpty(),
|
||||
field.Bool("verified").
|
||||
Default(false),
|
||||
field.String("email_verification_token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
field.String("password_reset_token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
field.Time("password_reset_expires_at").
|
||||
Optional(),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the User.
|
||||
func (User) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("user_roles", UserRole.Type),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user