-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
有 uniqueIndex 的情况下,AutoMigrate 再次执行会报错:Can't DROP 'xxx'; check that column/key exists #7010
Comments
是的,我也发生这样的报错 |
同步更新下driver版本 |
type PrivacyRule struct {
gorm.Model
Key string `gorm:"not null;uniqueIndex:idx_privacy_rule_key;"`
Pattern string `gorm:"not null;"`
} 更新到最新版本 1.25.10 的 gorm 给出了错误:
检查发现表里面有一个 constraint(不知道是哪个版本给生成了一个 idx_...... 的约束):
目前只知道在这个 commit 8fb9a31 只前的版本不会报错,这个 commit 之后的版本会报错。 |
发生错误 +1 ERROR: constraint "uni_v1_dict_uuid" of relation "v1_dict" does not exist (SQLSTATE 42704) |
I'm facing this same issue. Any unique column I declare will AutoMigrate the first time, but then fail (with no changes) trying to drop a constraint that does not exist. I'm using postgres/cockroackdb as the datastore |
I got same issue, I partially solved it by changing the version from |
连接mysql就更新这个驱动包 连接postgres就更新这个驱动包 执行下面的命令也可以 |
GORM Playground Link
go-gorm/playground#733
Description
执行
的时候,初次执行正常,再次执行报错:
实际上是没有这个外键的,但依然会drop这个外键。
预期结果:
判断此外键是否存在,存在再去执行 Drop 方法。
The text was updated successfully, but these errors were encountered: