| 269 | } |
| 270 | |
| 271 | func (s *SqliteMigrateSuite) TestMigrateDownFull(c *C) { |
| 272 | migrations := &FileMigrationSource{ |
| 273 | Dir: "test-migrations", |
| 274 | } |
| 275 | |
| 276 | n, err := Exec(s.Db, "sqlite3", migrations, Up) |
| 277 | c.Assert(err, IsNil) |
| 278 | c.Assert(n, Equals, 2) |
| 279 | |
| 280 | // Has data |
| 281 | id, err := s.DbMap.SelectInt("SELECT id FROM people") |
| 282 | c.Assert(err, IsNil) |
| 283 | c.Assert(id, Equals, int64(1)) |
| 284 | |
| 285 | // Undo the last one |
| 286 | n, err = Exec(s.Db, "sqlite3", migrations, Down) |
| 287 | c.Assert(err, IsNil) |
| 288 | c.Assert(n, Equals, 2) |
| 289 | |
| 290 | // Cannot query it anymore |
| 291 | _, err = s.DbMap.SelectInt("SELECT COUNT(*) FROM people") |
| 292 | c.Assert(err, Not(IsNil)) |
| 293 | |
| 294 | // Nothing left to do. |
| 295 | n, err = Exec(s.Db, "sqlite3", migrations, Down) |
| 296 | c.Assert(err, IsNil) |
| 297 | c.Assert(n, Equals, 0) |
| 298 | } |
| 299 | |
| 300 | func (s *SqliteMigrateSuite) TestMigrateTransaction(c *C) { |
| 301 | migrations := &MemoryMigrationSource{ |