forked from mirror/gorm
Refactor #1693
This commit is contained in:
parent
b9035a7602
commit
630c12b549
12
scope.go
12
scope.go
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue