The schemas were incomplete (empty stubs). Restored complete schemas from git history including refresh_token and user_role schemas, and proper field definitions for auditlog and user entities.
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
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),
|
|
}
|
|
}
|