我有2张表,
type QuantUser struct {
gorm.Model
UUID uuid.UUID `json:"uuid" gorm:"type:char(36);comment:用户UUID"`
Username string `json:"username" gorm:"unique;comment:用户登录名"`
Password string `json:"password" gorm:"comment:用户登录密码"`
Amount float64 `json:"amount" gorm:"comment:用户余额"`
Profit float64 `json:"profit" gorm:"comment:用户盈利"`
IsVip bool `json:"isVip" gorm:"comment:是否是VIP"`
VipEndTime string `json:"vipEndTime" gorm:"comment:VIP时间"`
ShareCode string `json:"shareCode" gorm:"comment:分享码"`
ShangjiCode string `json:"shangjiCode" gorm:"comment:码"`
ExchangeAPIs []TestApi `gorm:"foreignKey:UUID"`
}
type TestApi struct {
gorm.Model
UUID uuid.UUID `json:"uuid" gorm:"type:char(36);comment:用户UUID"`
ExchangeId int `json:"exchangeId" gorm:"comment:交易所ID"`
ApiKey string `json:"apiKey" gorm:"comment:API Key"`
SecretKey string `json:"secretKey" gorm:"comment:Secret Key"`
}
在自动迁移的时候,TestApi表创建表中UUID 类型被定义成了bigint unsigned , 明明我是定义成char(36), 如果把QuantUser表中的ExchangeAPIs []TestApi gorm:"foreignKey:UUID" 注释,TestApi表就会变成想要的UUID类型(char(36)),请问是什么原因导致的?
Comment From: github-actions[bot]
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 ✨