Skip to content

AutoMigrate failed on Postgres15 due to exist index name #6026

@axiangcoding

Description

@axiangcoding

GORM Playground Link

go-gorm/playground#561

Description

do AutoMigrate twice, it will failed on uniqueIndex column

type User struct {
	gorm.Model
	Name      string `gorm:"uniqueIndex;size:255"`
}

2023/02/04 17:37:52 /home/runner/go/pkg/mod/gorm.io/driver/postgres@v1.4.6/migrator.go:339 ERROR: relation "idx_users_name" already exists (SQLSTATE 42P07)
[0.881ms] [rows:0] ALTER TABLE "users" ADD CONSTRAINT "idx_users_name" UNIQUE("name")
    main_test.go:18: Failed, migrate error: ERROR: relation "idx_users_name" already exists (SQLSTATE 42P07)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions