Skip to content

Commit 915abc3

Browse files
crastinusAndrey Likhachev
and
Andrey Likhachev
authored
Disable add existing constraint (#145)
Co-authored-by: Andrey Likhachev <[email protected]>
1 parent 1d65db6 commit 915abc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

migrator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (m Migrator) AlterColumn(value interface{}, field string) error {
319319
}
320320
}
321321

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

0 commit comments

Comments
 (0)