-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL-描述表的结构体,给其属性添加autoIncrement 执行AutoMigrate()方法 数据库会新建一个索引 #6780
Comments
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 |
解决了吗 |
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 |
没有,先这么用着 |
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 |
我的结构体节选
type Site1 struct {
ID string
gorm:"size:25"
SerialNo uint32
gorm:"column:serialNo;not null;uniqueIndex:serialNo;autoIncrement"
Domain string
gorm:"size:30;not null;uniqueIndex:domain;comment:一级域名"
Domain2 string
gorm:"size:20;not null;uniqueIndex:domain;comment:二级域名"
}
因为我的表已经存在了所以没有使用gorm.Model
我执行db.AutoMigrate(&models.Site1{})后 结果如下表,多了个serialNo_2。将autoIncrement删除 问题消失
另外我还试了其它几种情况都会创建多个,执行一次db.AutoMigrate(&models.Site1{})创建一个类似,serialNo_3,serialNo_4,serialNo_5 ...
其它情况如下
SerialNo uint32
gorm:"column:serialNo;not null;unique;autoIncrement"
SerialNo uint32
gorm:"column:serialNo;not null;unique:serialNo;autoIncrement"
The text was updated successfully, but these errors were encountered: