(t *testing.T)
| 421 | } |
| 422 | |
| 423 | func TestMigrateTable(t *testing.T) { |
| 424 | type TableStruct struct { |
| 425 | gorm.Model |
| 426 | Name string |
| 427 | } |
| 428 | |
| 429 | DB.Migrator().DropTable(&TableStruct{}) |
| 430 | DB.AutoMigrate(&TableStruct{}) |
| 431 | |
| 432 | if !DB.Migrator().HasTable(&TableStruct{}) { |
| 433 | t.Fatalf("should found created table") |
| 434 | } |
| 435 | |
| 436 | type NewTableStruct struct { |
| 437 | gorm.Model |
| 438 | Name string |
| 439 | } |
| 440 | |
| 441 | if err := DB.Migrator().RenameTable(&TableStruct{}, &NewTableStruct{}); err != nil { |
| 442 | t.Fatalf("Failed to rename table, got error %v", err) |
| 443 | } |
| 444 | |
| 445 | if !DB.Migrator().HasTable("new_table_structs") { |
| 446 | t.Fatal("should found renamed table") |
| 447 | } |
| 448 | |
| 449 | DB.Migrator().DropTable("new_table_structs") |
| 450 | |
| 451 | if DB.Migrator().HasTable(&NewTableStruct{}) { |
| 452 | t.Fatal("should not found dropped table") |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | func TestMigrateWithQuotedIndex(t *testing.T) { |
| 457 | if DB.Dialector.Name() != "mysql" { |
nothing calls this directly
no test coverage detected