package auth import ( "encoding/json" "time" "github.com/google/uuid" "gorm.io/gorm" ) type UserModel struct { ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()"` FirstName string `gorm:"column:first_name;type:text;not null"` LastName string `gorm:"column:last_name;type:text;not null"` DisplayName string `gorm:"column:display_name;type:text;not null"` PhoneNumber string `gorm:"column:phone_number;type:text"` Email string `gorm:"column:email;type:text;not null;uniqueIndex:users_email_unique"` EmailVerified bool `gorm:"column:email_verified;type:boolean;default:false;not null"` Status int `gorm:"column:status;type:integer;default:0;not null"` InvitationCode string `gorm:"column:invitation_code;type:text"` CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null"` UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamptz;index"` } func (UserModel) TableName() string { return "users" } type RoleModel struct { ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()"` Name string `gorm:"column:name;type:text;not null;uniqueIndex:roles_name_unique"` Description *string `gorm:"column:description;type:text"` CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null"` UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamptz;index"` } func (RoleModel) TableName() string { return "roles" } type AccountModel struct { ID uuid.UUID `gorm:"type:uuid;primaryKey;default:gen_random_uuid()"` UserID uuid.UUID `gorm:"column:user_id;type:uuid;not null;index:accounts_user_id_idx"` Provider int `gorm:"column:provider;type:integer;index:accounts_provider_idx"` // For querying, also stored in meta Password *string `gorm:"column:password;type:text"` AccessToken *string `gorm:"column:access_token;type:text"` RefreshToken *string `gorm:"column:refresh_token;type:text"` Scope *string `gorm:"column:scope;type:text"` Meta *json.RawMessage `gorm:"column:meta;type:jsonb"` CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null"` UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null"` } func (AccountModel) TableName() string { return "accounts" } type UserRoleModel struct { UserID uuid.UUID `gorm:"column:user_id;type:uuid;not null;index:user_roles_user_id_idx"` RoleID uuid.UUID `gorm:"column:role_id;type:uuid;not null;index:user_roles_role_id_idx"` CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null"` UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamptz;index"` } func (UserRoleModel) TableName() string { return "user_roles" }