Skip to content

Commit 0d37bf2

Browse files
fix: create index failed without err (#285)
* fix: create index failed without err * fix createIndex always return err
1 parent daf17c1 commit 0d37bf2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

migrator.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,15 @@ func (m Migrator) CreateIndex(value interface{}, name string) error {
146146
createIndexSQL += " WHERE " + idx.Where
147147
}
148148

149-
return m.DB.Exec(createIndexSQL, values...).Error
149+
err := m.DB.Exec(createIndexSQL, values...).Error
150+
if err != nil {
151+
return err
152+
}
153+
154+
if !m.HasIndex(value, name) {
155+
return fmt.Errorf("failed to create index with name %v", name)
156+
}
157+
return nil
150158
}
151159
}
152160

0 commit comments

Comments
 (0)