Don't create index if there are error exist, close #3976

This commit is contained in:
Jinzhu 2021-01-24 10:23:04 +08:00
parent 35ebfe6874
commit f8bd4c4875
1 changed files with 3 additions and 1 deletions

View File

@ -183,7 +183,9 @@ func (m Migrator) CreateTable(values ...interface{}) error {
for _, idx := range stmt.Schema.ParseIndexes() {
if m.CreateIndexAfterCreateTable {
defer func(value interface{}, name string) {
errr = tx.Migrator().CreateIndex(value, name)
if errr == nil {
errr = tx.Migrator().CreateIndex(value, name)
}
}(value, idx.Name)
} else {
if idx.Class != "" {