fix: AutoMigrate with special table name (#5301)

* fix: AutoMigrate with special table name

* test: migrate with special table name
This commit is contained in:
Cr
2022-04-27 21:13:48 +08:00
committed by GitHub
parent 6a6dfdae72
commit bd7e42ec65
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -759,7 +759,8 @@ func (m Migrator) ReorderModels(values []interface{}, autoAdd bool) (results []i
Statement: &gorm.Statement{DB: m.DB, Dest: value},
}
beDependedOn := map[*schema.Schema]bool{}
if err := dep.Parse(value); err != nil {
// support for special table name
if err := dep.ParseWithSpecialTableName(value, m.DB.Statement.Table); err != nil {
m.DB.Logger.Error(context.Background(), "failed to parse value %#v, got error %v", value, err)
}
if _, ok := parsedSchemas[dep.Statement.Schema]; ok {