(c *C)
| 403 | } |
| 404 | |
| 405 | func (s *SqliteMigrateSuite) TestPlanMigrationWithHoles(c *C) { |
| 406 | up := "SELECT 0" |
| 407 | down := "SELECT 1" |
| 408 | migrations := &MemoryMigrationSource{ |
| 409 | Migrations: []*Migration{ |
| 410 | { |
| 411 | Id: "1", |
| 412 | Up: []string{up}, |
| 413 | Down: []string{down}, |
| 414 | }, |
| 415 | { |
| 416 | Id: "3", |
| 417 | Up: []string{up}, |
| 418 | Down: []string{down}, |
| 419 | }, |
| 420 | }, |
| 421 | } |
| 422 | n, err := Exec(s.Db, "sqlite3", migrations, Up) |
| 423 | c.Assert(err, IsNil) |
| 424 | c.Assert(n, Equals, 2) |
| 425 | |
| 426 | migrations.Migrations = append(migrations.Migrations, &Migration{ |
| 427 | Id: "2", |
| 428 | Up: []string{up}, |
| 429 | Down: []string{down}, |
| 430 | }) |
| 431 | |
| 432 | migrations.Migrations = append(migrations.Migrations, &Migration{ |
| 433 | Id: "4", |
| 434 | Up: []string{up}, |
| 435 | Down: []string{down}, |
| 436 | }) |
| 437 | |
| 438 | migrations.Migrations = append(migrations.Migrations, &Migration{ |
| 439 | Id: "5", |
| 440 | Up: []string{up}, |
| 441 | Down: []string{down}, |
| 442 | }) |
| 443 | |
| 444 | // apply all the missing migrations |
| 445 | plannedMigrations, _, err := PlanMigration(s.Db, "sqlite3", migrations, Up, 0) |
| 446 | c.Assert(err, IsNil) |
| 447 | c.Assert(plannedMigrations, HasLen, 3) |
| 448 | c.Assert(plannedMigrations[0].Id, Equals, "2") |
| 449 | c.Assert(plannedMigrations[0].Queries[0], Equals, up) |
| 450 | c.Assert(plannedMigrations[1].Id, Equals, "4") |
| 451 | c.Assert(plannedMigrations[1].Queries[0], Equals, up) |
| 452 | c.Assert(plannedMigrations[2].Id, Equals, "5") |
| 453 | c.Assert(plannedMigrations[2].Queries[0], Equals, up) |
| 454 | |
| 455 | // first catch up to current target state 123, then migrate down 1 step to 12 |
| 456 | plannedMigrations, _, err = PlanMigration(s.Db, "sqlite3", migrations, Down, 1) |
| 457 | c.Assert(err, IsNil) |
| 458 | c.Assert(plannedMigrations, HasLen, 2) |
| 459 | c.Assert(plannedMigrations[0].Id, Equals, "2") |
| 460 | c.Assert(plannedMigrations[0].Queries[0], Equals, up) |
| 461 | c.Assert(plannedMigrations[1].Id, Equals, "3") |
| 462 | c.Assert(plannedMigrations[1].Queries[0], Equals, down) |
nothing calls this directly
no test coverage detected