gorm.io/gorm v1.22.5
db: mysql
1、Delete primary key do NOT work
type TestB struct {
AColumn string `gorm:"column:a;"
BColumn int64 `gorm:"primaryKey;column:b;"
CColumn int64 `gorm:"primaryKey;column:c;"
}
err := db.Debug().Table("table_b").AutoMigrate(&TestB{})
will create table_b with create primary key
PRIMARY KEY (`b`,`c`)
I modify CColumn tag to : gorm:"column:c;" to update table primary key to PRIMARY KEY (`b`), but it NOT working.
type TestB struct {
AColumn string `gorm:"column:a;"
BColumn int64 `gorm:"primaryKey;column:b;"
CColumn int64 `gorm:"column:c;"
}
err := db.Debug().Table("table_b").AutoMigrate(&TestB{})
err = db.Debug().Table("table_b").Migrator().AlterColumn(&TestB{}, "CColumn")
(primaryKey also is b,c NOT b)
2、Add primary key do NOT work
type TestB struct {
AColumn string `gorm:"column:a;"`
BColumn int64 `gorm:"primaryKey;column:b;"`
}
err := db.Debug().Table("table_b").AutoMigrate(&TestB{})
with create primary key PRIMARY KEY (`b`)
add a new CColumn to update primaryKey to b,c
type TestB struct {
AColumn string `gorm:"column:a;"`
BColumn int64 `gorm:"primaryKey;column:b;"`
CColumn int64 `gorm:"primaryKey;column:c;"`
}
err := db.Debug().Table("table_b").AutoMigrate(&TestB{})
err = db.Debug().Table("table_b").Migrator().AddColumn(&TestB{}, "CColumn")`
Also NOT woking (primaryKey also is b, not b,c)
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 ✨
Comment From: sasakiyori
I meet the same problem with postgresql.
When I change the primary key settings, AutoMigrate doesn't effect.
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 ✨
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 ✨
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 ✨
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 ✨
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 ✨
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 ✨