修复:软删除账号可复用用户名

This commit is contained in:
yml2213
2026-08-13 14:40:22 +08:00
parent 91c055c130
commit 33a30fcd99
3 changed files with 29 additions and 1 deletions
+3 -1
View File
@@ -19,7 +19,9 @@ type User struct {
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Username string `gorm:"uniqueIndex;size:64;not null" json:"username"`
// Username uniqueness is enforced by a partial database index for active
// accounts, allowing a username to be reused after its old account is soft deleted.
Username string `gorm:"size:64;not null" json:"username"`
PasswordHash string `gorm:"size:255;not null" json:"-"`
Nickname string `gorm:"size:64" json:"nickname"`
Role string `gorm:"size:32;not null;default:merchant" json:"role"`