mirror of https://github.com/go-gorm/gorm.git
AutoMigrate should auto create indexes, close #3486
This commit is contained in:
parent
c9165fe3ca
commit
089939c767
|
@ -133,6 +133,15 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, idx := range stmt.Schema.ParseIndexes() {
|
||||
if !tx.Migrator().HasIndex(value, idx.Name) {
|
||||
if err := tx.Migrator().CreateIndex(value, idx.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue