Skip to content

Unnecessarily unique indexes created when running AutoMigrate #6224

@shanehou

Description

@shanehou

GORM Playground Link

go-gorm/playground#589

Description

Model User has only one field Name, with uniqueIndex tag. First time I run AutoMigrate, GORM will create two unique indexes called idx_users_name and name. Then every time I run AutoMigrate, GORM will create a new unique index called name_2, name_3 and so on.

If I use uniqueIndex:i_u_name to specify the name of the unique index, the first run would still create i_u_name and name indexes, and the following runs would still create name_2, name_3 indexes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions