Comments (7)
I got same issue, I partially solved it by changing the version from v1.25.9
to v1.25.5
.
from gorm.
是的,我也发生这样的报错
from gorm.
同步更新下driver版本
from gorm.
type PrivacyRule struct {
gorm.Model
Key string `gorm:"not null;uniqueIndex:idx_privacy_rule_key;"`
Pattern string `gorm:"not null;"`
}
更新到最新版本 1.25.10 的 gorm 给出了错误:
time="2024-05-14T10:16:32+08:00" level=error msg="migrate failed: ERROR: constraint "uni_privacy_rules_key" of relation "privacy_rules" does not exist (SQLSTATE 42704)"
检查发现表里面有一个 constraint(不知道是哪个版本给生成了一个 idx_...... 的约束):
Indexes:
"privacy_rules_pkey" PRIMARY KEY, btree (id)
"idx_privacy_rule_key" UNIQUE, btree (key)
"idx_privacy_rules_deleted_at" btree (deleted_at)
"idx_privacy_rules_key" UNIQUE CONSTRAINT, btree (key) // → 生成了未指定的 CONSTRAINT
目前只知道在这个 commit 8fb9a31 只前的版本不会报错,这个 commit 之后的版本会报错。
from gorm.
发生错误 +1
ERROR: constraint "uni_v1_dict_uuid" of relation "v1_dict" does not exist (SQLSTATE 42704)
from gorm.
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
from gorm.
连接mysql就更新这个驱动包
gorm.io/driver/mysql v1.5.6
连接postgres就更新这个驱动包
gorm.io/driver/postgres v1.5.7
执行下面的命令也可以
go get gorm.io/driver/mysql@latest
go get gorm.io/driver/postgres@latest
from gorm.
Related Issues (20)
- 为什么find函数里必须传入slice的指针呢,slice本身不就是引用类型吗 HOT 8
- breaks 1.21 to 1.22 HOT 5
- Schema missing when MERGE is executed using Save() method. HOT 1
- FOREIGN KEY constraint failed (1811) on AutoMigrate when set `foreign_keys` ON for SQLite HOT 2
- Can gorm return db default value after create HOT 1
- How to add a hint into Raw SQL?
- `ERRO[0000] near "(": syntax error ` in automigraion for sqlite db. HOT 1
- 请教一个用法 HOT 3
- Wiki link not up to date HOT 2
- Breaking change : define a valid foreign key for relations or implement the Valuer/Scanner interface
- passing struct address through empty interface cannot be success of Save() & Create() & Delete()
- gorm v2.0 unit testing with sqlmock does not work with Postgres uint HOT 1
- Error: simple protocol queries must be run with client_encoding=UTF8 HOT 1
- Query Operation in After Update Callback Causes RowsAffected to be 0 HOT 3
- cannot find encode plan HOT 1
- Updates 使用 struct 作为参数无法触发 BeforeUpdate 钩子 HOT 12
- Omitting a column from the result
- Alias for AutoMigrate
- Release Savepoint
- Could you explain to me why you don't report an error when the specified serializer is not found?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gorm.