Coder Social home page Coder Social logo

Comments (7)

davisfelipe avatar davisfelipe commented on June 11, 2024 1

I got same issue, I partially solved it by changing the version from v1.25.9 to v1.25.5.

from gorm.

smnilu avatar smnilu commented on June 11, 2024

是的,我也发生这样的报错

from gorm.

eslizn avatar eslizn commented on June 11, 2024

同步更新下driver版本

from gorm.

haoran-mc avatar haoran-mc commented on June 11, 2024
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.

whatwewant avatar whatwewant commented on June 11, 2024

发生错误 +1

 ERROR: constraint "uni_v1_dict_uuid" of relation "v1_dict" does not exist (SQLSTATE 42704)

from gorm.

siosphere avatar siosphere commented on June 11, 2024

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.

qaqhy avatar qaqhy commented on June 11, 2024

连接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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.