优化用户模型 Email 字段长度限制

- 为 Email 字段添加 varchar(191) 类型约束
- 确保数据库兼容性和索引性能
This commit is contained in:
wood chen 2025-03-06 23:37:14 +08:00
parent aeb05f790a
commit 31f65a9301

View File

@ -9,7 +9,7 @@ import (
type User struct { type User struct {
ID uint `json:"id" gorm:"primaryKey"` ID uint `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"not null;unique"` Username string `json:"username" gorm:"not null;unique"`
Email string `json:"email" gorm:"not null"` Email string `json:"email" gorm:"not null;type:varchar(191)"`
Role string `json:"role" gorm:"not null;default:user"` // admin or user Role string `json:"role" gorm:"not null;default:user"` // admin or user
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`