Merge branch 'WingGao-path1'

This commit is contained in:
Jinzhu 2018-01-31 17:14:33 +08:00
commit 1856135e10
1 changed files with 6 additions and 2 deletions

View File

@ -1228,11 +1228,15 @@ func (scope *Scope) autoIndex() *Scope {
}
for name, columns := range indexes {
scope.NewDB().Model(scope.Value).AddIndex(name, columns...)
if db := scope.NewDB().Model(scope.Value).AddIndex(name, columns...); db.Error != nil {
scope.db.AddError(db.Error)
}
}
for name, columns := range uniqueIndexes {
scope.NewDB().Model(scope.Value).AddUniqueIndex(name, columns...)
if db := scope.NewDB().Model(scope.Value).AddUniqueIndex(name, columns...); db.Error != nil {
scope.db.AddError(db.Error)
}
}
return scope