Playground link doesn't make any sense, as I'd need to use multiple versions at once.
Say you have the following model:
type User struct {
BaseModel
// The user's email address
Email string `gorm:"not null;uniqueIndex:idx_user_email" json:"email"`
}
Migrating with:
tx.AutoMigrate(&domain.User{})
Causes:
2024/03/10 22:09:04 ERROR: constraint "uni_users_email" of relation "users" does not exist (SQLSTATE 42704)
[0.697ms] [rows:0] ALTER TABLE "users" DROP CONSTRAINT "uni_users_email"
I'd appreciate, if releases would be properly tested beforehand. I'll be pinning 1.2.5 for now.
link for not being marked as stale: https://github.com/go-gorm/playground/issues/0
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: ChristianSch
v1.25.7-0.20240204074919-46816ad31dde works
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: klipach
Have the same issue while using v1.25.9 and PostgreSQL. Downgrading to v1.25.5 resolves the issue.
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: zetaab
we are also seeing this
2024/04/09 05:52:14 pq: constraint "uni_image_statistics_image_id" of relation "image_statistics" does not exist
[0.955ms] [rows:0] ALTER TABLE "image_statistics" DROP CONSTRAINT "uni_image_statistics_image_id"
"error":"pq: constraint \"uni_image_statistics_image_id\" of relation \"image_statistics\" does not exist"
using gorm 1.25.9 and gorm postgres 1.5.7
in our case the model is
type ImageStatistics struct {
Model `json:"-"`
ImageID string `json:"image_id" gorm:"index:idx_image_id,unique"`
...
}
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: UninspiredNickname
I can confirm that - this error happens because in https://github.com/go-gorm/gorm/blob/v1.25.9/migrator/migrator.go#L569 field.Unique
returns false
when UniqueIndex
is used on the models
Simply swapping it to unique;index
fixed the problem for me, but field.Unique
should be set to true if uniqueIndex
is used
Comment From: varfrog
I wish this library: 1. used proper versioning - semver 2.0.0 or go's /vX for breaking changes 2. had a changelog 3. test the changes big asks fsho... I don't expect any of these to be implemented though. Who versions their libraries anyways... changelog? c'mon...
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: PaulSonOfLars
+1 on this issue. Also noticed this upon upgrading from 1.25.5 to 1.25.9.
This may be helpful for debugging the root cause -
I noticed that creating tables on 1.25.5 and 1.25.9 results in different table metadata, which is likely related.
Looking at the \d+
output of a table:
- 1.25.5
creates an idx_<table>_<column>
index, as a UNIQUE CONSTRAINT
.
- 1.25.9
creates an idx_<column>
index, but only as UNIQUE
; not as a constraint.
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: ChristianSch
Not stale. Doesn't look fixed to me. @jinzhu
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: PaulSonOfLars
If all it wants is a playground link... Will this work? https://github.com/go-gorm/playground/issues/0
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: ChristianSch
Lol this bot is stupid. I added the playground link to the first message ...
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: varfrog
Lol this bot is stupid. I added the playground link to the first message ...
What it needs is a link to a pull request in the playground repo. See example how it is here: https://github.com/go-gorm/gorm/issues/6963 - it links to a playground PR where the PR code is a reproducer for the bug
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: ChristianSch
@varfrog that ticket is marked as stale as well. I don't understand how and why I'd even want to open a PR to anywhere for this topic.
As I'm migrating off of this library, I'll also unsubscribe to this PR. Gorm is not something I'm interested in using anymore.
Comment From: klipach
@ChristianSch do you know some good alternatives? I'm also planning to migrate to some other tool
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: ChristianSch
@klipach pgx + scany is what I'm using
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: Sophie1142
I am also encountering this issue after upgrading from v1.25.5 to v1.25.9. The (abbreviated) definition of my model is:
type Service struct {
gorm.Model
Name string `json:"name"`
Nickname string `gorm:"default:NULL;uniqueIndex;check:((nickname IS NOT NULL AND NOT nickname = '' AND nickname ~ '^[a-z0-9_-]+$') OR quick_quote_config_id IS NULL)"`
ConfigID *uint `json:"-" gorm:"default:null;check:chk_services_config,(config_id IS NOT NULL OR nickname IS NULL)"`
Config *Config `json:"-"``
}
Pinning to v1.25.5 solved my issue.
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: PaulSonOfLars
Requesting to reopen this @jinzhu - this is a breaking change that is impacting multiple people
Comment From: zetaab
we are migrating away from gorm, there has been too many issues like this. Our weapon of choice is go-migrate and sqlx.
Comment From: abhijit-hota
The versioning in this library is so cursed. Just got hit by what seemed like a patched version. (1.25.2 -> 1.25.10
)