From fb7768f31682b5a2ecbf4b18a468d7881cfab14c Mon Sep 17 00:00:00 2001 From: fwhez <1728565484@qq.com> Date: Mon, 12 Nov 2018 14:17:56 +0800 Subject: [PATCH] Fix bug 'table user, animal not found' --- migration_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration_test.go b/migration_test.go index 3fb06648..c81670d3 100644 --- a/migration_test.go +++ b/migration_test.go @@ -294,7 +294,9 @@ func runMigration() { values := []interface{}{&Short{}, &ReallyLongThingThatReferencesShort{}, &ReallyLongTableNameToTestMySQLNameLengthLimit{}, &NotSoLongTableName{}, &Product{}, &Email{}, &Address{}, &CreditCard{}, &Company{}, &Role{}, &Language{}, &HNPost{}, &EngadgetPost{}, &Animal{}, &User{}, &JoinTable{}, &Post{}, &Category{}, &Comment{}, &Cat{}, &Dog{}, &Hamster{}, &Toy{}, &ElementWithIgnoredField{}, &Place{}} for _, value := range values { - DB.DropTable(value) + if DB.HasTable(value){ + DB.DropTable(value) + } } if err := DB.AutoMigrate(values...).Error; err != nil { panic(fmt.Sprintf("No error should happen when create table, but got %+v", err))