-
-
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
Unique field always causes field migration #5950
Comments
uniqueIndex
causes field migrationuniqueIndex
always causes field migration
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 |
uniqueIndex
always causes field migration
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 |
Seems like #5942 is the same issue. |
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 |
Should be fixed in commit 3d91802 |
GORM Playground Link
No time to make it for now.
Description
unique
Field (havinguniqueIndex
orindex:,unique
tag) always causes migration.The reason is this line:
gorm/schema/field.go
Line 116 in 7da24d1
field.Unique
is only true whentagSettings["UNIQUE"]
is true.But
uniqueIndex
tag only setstagSettings["UNIQUEINDEX"]
andindex
tag only setstagSettings["INDEX"]
.And field migration is checking
field.Unique
in this line:gorm/migrator/migrator.go
Line 481 in 7da24d1
Therefore field migration will always be performed.
Maybe
schema/field.go#L116
should be changed toBut I don't think this treatment is good. Does
field.Unique
deserve to exist?The text was updated successfully, but these errors were encountered: