I'm working on a migration using Sequelize. If the migration up method throws an error, the migration is not logged in the database as having completed. So, if I run db:migrate:undo, it instead runs down on the previous (and working) migration. As a result, I have a half executed migration where the schema for it remains in the database because the corresponding down method is never run by Sequelize. So, I need to either somehow force a single down method to run (which I'm not seeing an option for). Or, I need to manually clean up my database every time I run a failing migration, which can be a real pain for complicated migrations where I'm constantly going through trial and error. Is there an easier way to doing this?
2
votes
4 Answers
3
votes
1
votes
1
votes
0
votes
I tried something and it worked for me:
- rename your migration file and make sure it comes first alphabetically (make it the first one in migration files)
- comment code in the second migration file
- run
sequelize db:migrate
This will run only the first migration file.
Don't forget to uncomment the migration file you commented before