Skip to content

Commit

Permalink
fix: create index failed without err (#285)
Browse files Browse the repository at this point in the history
* fix: create index failed without err

* fix createIndex always return err
  • Loading branch information
zhangzhiqiangcs authored Sep 23, 2024
1 parent daf17c1 commit 0d37bf2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,15 @@ func (m Migrator) CreateIndex(value interface{}, name string) error {
createIndexSQL += " WHERE " + idx.Where
}

return m.DB.Exec(createIndexSQL, values...).Error
err := m.DB.Exec(createIndexSQL, values...).Error
if err != nil {
return err
}

if !m.HasIndex(value, name) {
return fmt.Errorf("failed to create index with name %v", name)
}
return nil
}
}

Expand Down

0 comments on commit 0d37bf2

Please sign in to comment.