sequelize/sequelize — pull request #2300 by jtschoonhoven (2014-09-19 00:41:41+00:00)
Title: Fix for issue #1829: down migrations operate only on *completed* migrations

**Issue**
In [/lib/migrator.js](https://github.com/sequelize/sequelize/blob/master/lib/migrator.js), down migrations take place within the [getUndoneMigrations](https://github.com/sequelize/sequelize/blob/master/lib/migrator.js#L36) callback. A migration that *should* be undone will never exist in the array of migrations that *have* been undone and so down migrations will never occur.

**Fix**
Down migrations now occur in a "getCompletedMigrations" callback. It will only run a down migration for files that have a record in the db more recent than the timestamp on the file. Down migrations call "deleteUndoneMigration" when finished to remove the migration record from the db. Added several tests for getCompletedMigrations.