This commit is contained in:
Jinzhu 2018-01-31 17:14:21 +08:00
parent b9035a7602
commit 630c12b549
1 changed files with 4 additions and 8 deletions

View File

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