How do I define my struct
s to specify a multi-column unique index to Gorm in Go?
Such as:
type Something struct {
gorm.Model
First string `sql:"unique_index:unique_index_with_second"`
Second string `sql:"unique_index:unique_index_with_first"`
}
Are you trying to create a table so that the combination of First and Second is unique?
This should work :
type Something struct {
ID uint
gorm.Model
First string `gorm:"primary_key"`
Second string `gorm:"primary_key"`
}