diff --git a/config/config.go b/config/config.go index 80b2e65..abd66e4 100644 --- a/config/config.go +++ b/config/config.go @@ -174,13 +174,27 @@ func (c *Config) GetMigrationFunc(dbDialect string) models.MigrationFunc { switch dbDialect { default: return func(db *gorm.DB) error { - db.AutoMigrate(&models.User{}) - db.AutoMigrate(&models.KeyStringValue{}) - db.AutoMigrate(&models.Alias{}) - db.AutoMigrate(&models.Heartbeat{}) - db.AutoMigrate(&models.Summary{}) - db.AutoMigrate(&models.SummaryItem{}) - db.AutoMigrate(&models.LanguageMapping{}) + if err := db.AutoMigrate(&models.User{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.KeyStringValue{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.Alias{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.Heartbeat{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.Summary{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.SummaryItem{}); err != nil { + return err + } + if err := db.AutoMigrate(&models.LanguageMapping{}); err != nil { + return err + } return nil } } diff --git a/models/user.go b/models/user.go index 031b0f1..988634f 100644 --- a/models/user.go +++ b/models/user.go @@ -9,7 +9,7 @@ func init() { type User struct { ID string `json:"id" gorm:"primary_key"` ApiKey string `json:"api_key" gorm:"unique"` - Email string `json:"email" gorm:"uniqueIndex:idx_user_email"` + Email string `json:"email" gorm:"uniqueIndex:idx_user_email; size:255"` Password string `json:"-"` CreatedAt CustomTime `gorm:"type:timestamp; default:CURRENT_TIMESTAMP" swaggertype:"string" format:"date" example:"2006-01-02 15:04:05.000"` LastLoggedInAt CustomTime `gorm:"type:timestamp; default:CURRENT_TIMESTAMP" swaggertype:"string" format:"date" example:"2006-01-02 15:04:05.000"`