Add MySQL initialization and user model size constraint

This commit is contained in:
koh
2025-04-12 15:54:30 +07:00
parent d83f6c1145
commit 82e7fd1d01
3 changed files with 19 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ import (
// User đại diện cho người dùng trong hệ thống
type User struct {
ID uint `json:"id" gorm:"primaryKey"`
Username string `json:"username" gorm:"uniqueIndex;not null"`
Username string `json:"username" gorm:"uniqueIndex;not null;size:255"`
Password string `json:"-" gorm:"not null"` // Không trả về password trong JSON
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`