GORM Playground Link
https://github.com/go-gorm/playground/pull/285
Description
When a user wants to add a unique constraint on a column, the unique constraint is not added by AutoMigrate().
When creating a new table, the constraint is added.
When adding a unique index on an existing column, the migration is applied.
The MigrateColumn function do not seems to handle unique fields : https://github.com/go-gorm/gorm/blob/2ba612e80591c26ef512af629d2e1532fc48b5b9/migrator/migrator.go#L363-L404
Thanks !
Comment From: jinzhu
auto migration will only migrate missing indexes, but not constraint currently.
Comment From: jinzhu
Added its support in v1.23.1, thank you for your support.
Comment From: progmatic-99
I first added the unique constraint on the column and migrated it, but then I removed the unique constraint. But the table doesn't reflect this change.
Any ideas??
Comment From: hinupurthakur
@progmatic-99 Were you able to find an elegant way to do so?
I first added the
uniqueconstraint on the column and migrated it, but then I removed theuniqueconstraint. But the table doesn't reflect this change. Any ideas??