forked from mirror/gorm
Allow customize table name when creating index, close #1656
This commit is contained in:
parent
49934ff3bf
commit
7e2bb3d7fa
4
scope.go
4
scope.go
|
@ -1250,13 +1250,13 @@ func (scope *Scope) autoIndex() *Scope {
|
|||
}
|
||||
|
||||
for name, columns := range indexes {
|
||||
if db := scope.NewDB().Model(scope.Value).AddIndex(name, columns...); db.Error != nil {
|
||||
if db := scope.NewDB().Table(scope.TableName()).Model(scope.Value).AddIndex(name, columns...); db.Error != nil {
|
||||
scope.db.AddError(db.Error)
|
||||
}
|
||||
}
|
||||
|
||||
for name, columns := range uniqueIndexes {
|
||||
if db := scope.NewDB().Model(scope.Value).AddUniqueIndex(name, columns...); db.Error != nil {
|
||||
if db := scope.NewDB().Table(scope.TableName()).Model(scope.Value).AddUniqueIndex(name, columns...); db.Error != nil {
|
||||
scope.db.AddError(db.Error)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue