Skip to content

Commit d815729

Browse files
authored
Fix creating unique index on non-unique field (#168)
(which would be created multiple times and fail during migration)
1 parent 449c37a commit d815729

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

migrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, co
109109
return err
110110
}
111111
}
112-
if field.UniqueIndex != "" {
112+
if field.UniqueIndex != "" && !queryTx.Migrator().HasIndex(value, field.UniqueIndex) {
113113
if err := execTx.Migrator().CreateIndex(value, field.UniqueIndex); err != nil {
114114
return err
115115
}

0 commit comments

Comments
 (0)