go-gorm / postgres

GORM PostgreSQL driver
MIT License
234 stars 123 forks source link

ERROR: relation "idx_xxx" already exists (SQLSTATE 42P07) #151

Closed microyahoo closed 1 year ago

microyahoo commented 1 year ago

GORM Playground Link

https://github.com/go-gorm/playground/pull/1

Description

2022/12/28 02:48:33 /root/go/src/deeproute.ai/smd/vendor/gorm.io/driver/postgres/migrator.go:271 ERROR: relation "idx_cephfs_subvolumes_subvolume_name" already exists (SQLSTATE 42P07)
[0.650ms] [rows:0] ALTER TABLE "cephfs_subvolumes" ADD CONSTRAINT "idx_cephfs_subvolumes_subvolume_name" UNIQUE("subvolume_name")
I1228 02:48:33.476777       1 log.go:198] ERROR: relation "idx_cephfs_subvolumes_subvolume_name" already exists (SQLSTATE 42P07)
microyahoo commented 1 year ago

The probability of this problem occurring at pod startup is very high. It'd better to check whether the constraint has existed or not before create it.

microyahoo commented 1 year ago

The fix has been merged https://github.com/go-gorm/postgres/pull/145. Please help to create a new tag, thanks. @jinzhu