Skip to content

AutoMigrate drop unique index that already exists on mysql table #7670

@seanlook

Description

@seanlook

Your Question

I've a column definition like:

EventUuid string `json:"event_uuid" gorm:"type:varchar(60)"

There's no unique constraint. In my situation, I add a unique index on this table

ALTER TABLE ADD UNIQUE INDEX uk_eventuuid(event_uuid)

Then when I run db.Migrator().AutoMigrate(&m), the unique index is dropped

The document you expected this should be explained

Does this is a feature or bug?

Expected answer

If it's a feature, the docs need to mention it out. But I prefer it as an unexpected bug, because it removed my unique index.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions