| 298 | } |
| 299 | |
| 300 | func (s *SqliteMigrateSuite) TestMigrateTransaction(c *C) { |
| 301 | migrations := &MemoryMigrationSource{ |
| 302 | Migrations: []*Migration{ |
| 303 | sqliteMigrations[0], |
| 304 | sqliteMigrations[1], |
| 305 | { |
| 306 | Id: "125", |
| 307 | Up: []string{"INSERT INTO people (id, first_name) VALUES (1, 'Test')", "SELECT fail"}, |
| 308 | Down: []string{}, // Not important here |
| 309 | }, |
| 310 | }, |
| 311 | } |
| 312 | |
| 313 | // Should fail, transaction should roll back the INSERT. |
| 314 | n, err := Exec(s.Db, "sqlite3", migrations, Up) |
| 315 | c.Assert(err, Not(IsNil)) |
| 316 | c.Assert(n, Equals, 2) |
| 317 | |
| 318 | // INSERT should be rolled back |
| 319 | count, err := s.DbMap.SelectInt("SELECT COUNT(*) FROM people") |
| 320 | c.Assert(err, IsNil) |
| 321 | c.Assert(count, Equals, int64(0)) |
| 322 | } |
| 323 | |
| 324 | func (s *SqliteMigrateSuite) TestPlanMigration(c *C) { |
| 325 | migrations := &MemoryMigrationSource{ |