version: 1.22.5; mysql
Description
PlatformId string `gorm:"uniqueIndex,size:256,not null"`
PlatformNumber string `gorm:"uniqueIndex,size:256,not null"`
no index created
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 2 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 ✨
Comment From: li-jin-gou
hello @loeffel-io tag need use ; to as separator.
code in mysql :
type TestModel struct {
gorm.Model
PlatformId string `gorm:"uniqueIndex;size:256;not null"`
PlatformNumber string `gorm:"uniqueIndex;size:256;not null"`
}
func TestGORM(t *testing.T) {
DB.Debug().Migrator().DropTable(&TestModel{})
DB.Debug().Migrator().AutoMigrate(TestModel{})
}
result:
2022/02/04 21:11:06 /Users/hale/go/src/github.com/longlihale/playground/main_test.go:20
[18.305ms] [rows:0] CREATE TABLE `test_models` (`id` bigint unsigned AUTO_INCREMENT,`created_at` datetime(3) NULL,`updated_at` datetime(3) NULL,`deleted_at` datetime(3) NULL,`platform_id` varchar(256) NOT NULL,`platform_number` varchar(256) NOT NULL,PRIMARY KEY (`id`),INDEX idx_test_models_deleted_at (`deleted_at`),UNIQUE INDEX idx_test_models_platform_id (`platform_id`),UNIQUE INDEX idx_test_models_platform_number (`platform_number`))
--- PASS: TestGORM (0.03s)
Comment From: loeffel-io
omfg 😂 sorry for this one!
Comment From: li-jin-gou
omfg 😂 sorry for this one!
look look it https://github.com/go-gorm/gorm/issues/5049