From 31f65a9301adf2e4058fffbaa9cb25b5cb2e0e2f Mon Sep 17 00:00:00 2001 From: wood chen Date: Thu, 6 Mar 2025 23:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=20Email=20=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 Email 字段添加 varchar(191) 类型约束 - 确保数据库兼容性和索引性能 --- backend/models/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/models/user.go b/backend/models/user.go index e6f42ae..6f543c3 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -9,7 +9,7 @@ import ( type User struct { ID uint `json:"id" gorm:"primaryKey"` 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 CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`