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 {
|
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)
|
scope.db.AddError(db.Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, columns := range uniqueIndexes {
|
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)
|
scope.db.AddError(db.Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user