You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using AutoMigrate as a method of database updates. But when I added some fields to the model, this function reported an error
database: postgres:14.4
gorm version v1.23.8
struct GameUser was
type GameUser struct {
gorm.Model
XXX1 string `gorm:"uniqueIndex;size:255"`
XXX2 string `gorm:"size:255"`
StatAb UserStat `gorm:"embedded;embeddedPrefix:stat_ab_"`
StatRb UserStat `gorm:"embedded;embeddedPrefix:stat_rb_"`
StatSb UserStat `gorm:"embedded;embeddedPrefix:stat_sb_"`
}
type UserStat struct {
TotalMission int
WinRate float64
GroundDestroyCount int
FleetDestroyCount int
GameTime string
AviationDestroyCount int
WinCount int
SliverEagleEarned int64
DeadCount int
}
And i did some modification to struct GameUser
type GameUser struct {
gorm.Model
XXX1 string `gorm:"uniqueIndex;size:255"`
XXX2 string `gorm:"size:255"`
StatAb UserStat `gorm:"embedded;embeddedPrefix:stat_ab_"`
StatRb UserStat `gorm:"embedded;embeddedPrefix:stat_rb_"`
StatSb UserStat `gorm:"embedded;embeddedPrefix:stat_sb_"`
// new fields
GroundRateAb GroundRate `gorm:"embedded;embeddedPrefix:rate_ground_ab_"`
GroundRateRb GroundRate `gorm:"embedded;embeddedPrefix:rate_ground_rb_"`
GroundRateSb GroundRate `gorm:"embedded;embeddedPrefix:rate_ground_sb_"`
}
type UserStat struct {
TotalMission int
WinRate float64
GroundDestroyCount int
FleetDestroyCount int
GameTime string
AviationDestroyCount int
WinCount int
SliverEagleEarned int64
DeadCount int
}
type GroundRate struct {
GameCount int
GroundVehicleGameCount int
TDGameCount int
HTGameCount int
SPAAGameCount int
GameTime string
GroundVehicleGameTime string
TDGameTime string
HTGameTime string
SPAAGameTime string
TotalDestroyCount int
AviationDestroyCount int
GroundDestroyCount int
FleetDestroyCount int
}
If game_user not in the database, it works well, new table game_user will be created. But when the table game_user which created by old struct exists, AutoMigrate error occurs. Error is
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
GORM Playground Link
go-gorm/playground#515
Description
I am using AutoMigrate as a method of database updates. But when I added some fields to the model, this function reported an error
database: postgres:14.4
gorm version v1.23.8
struct
GameUser
wasAnd i did some modification to struct
GameUser
If
game_user
not in the database, it works well, new tablegame_user
will be created. But when the tablegame_user
which created by old struct exists, AutoMigrate error occurs. Error isit appears something wrong here. Anyone facing the same issue?
The text was updated successfully, but these errors were encountered: