How to delete a migration using sequalize-cli
In your case, you must add the deleted migration file back in because Sequelize requires it to roll back your migrations. If you don't have it, you can add a blank migration file titled 20171125081136-create-task.js
. The file must have a down
function that returns a successful promise.
'use strict';
module.exports = {
up: function(queryInterface, Sequelize) {
return Promise.resolve()
},
down: function(queryInterface) {
return Promise.resolve()
}
};
Going forward, if you want to delete a migration:
- Undo the latest migration:
node_modules/.bin/sequelize db:migrate:undo
- Delete the latest migration file
I was getting the same issue an this is how I solved it:
Sequelize stores the migration history within a separate table, ex "SequelizeMeta". If you delete a migration file and no longer want to use it after, you can remove the migration rows corresponding to your migration file from the SequelizeMeta table.
Hope that helps!