Skip to content

Commit

Permalink
Disable add existing constraint (#145)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Likhachev <likhachev@bifit.int>
  • Loading branch information
crastinus and Andrey Likhachev committed Dec 24, 2022
1 parent 1d65db6 commit 915abc3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion migrator.go
Expand Up @@ -319,7 +319,7 @@ func (m Migrator) AlterColumn(value interface{}, field string) error {
}
}

if uniq, _ := fieldColumnType.Unique(); uniq != field.Unique {
if uniq, _ := fieldColumnType.Unique(); !uniq && field.Unique {
idxName := clause.Column{Name: m.DB.Config.NamingStrategy.IndexName(stmt.Table, field.DBName)}
if err := m.DB.Exec("ALTER TABLE ? ADD CONSTRAINT ? UNIQUE(?)", m.CurrentTable(stmt), idxName, clause.Column{Name: field.DBName}).Error; err != nil {
return err
Expand Down

0 comments on commit 915abc3

Please sign in to comment.