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
type A struct{
Id int64 `gorm:"primaryKey"`
Bs []B `gorm:"foreignKey:MyID"`
}
type B struct{
MyID string `gorm:"primaryKey"`
}
...
var models = []interface{}{A{},B{}}
db.AutoMigrate(models...)
Create on postgres db level:
A: id:bigint
B: my_id: bigint (!)
Expected answer
The primary key of B should be a String as defined in the gorm syntax.... Or am I doing something wrong?
Your Question
Is it possible to use a String as a specific ForeignKey ? Using PostgreSQL Adapter
The document you expected this should be explained
https://gorm.io/docs/has_many.html offers the possibility to change the default foreignKey.
Example:
Create on postgres db level:
Expected answer
The primary key of B should be a String as defined in the gorm syntax.... Or am I doing something wrong?
P.S. Is this related to go-gorm/postgres#111
The text was updated successfully, but these errors were encountered: