knex-migrate
knex-migrate copied to clipboard
Running with `--only` should not fail if migration has already been run
When a migration has already been run, right now it bails out saying that the specified migration is not pending, and exits with an error status.
I think in a scenario where the specified migration doesn't exist, it makes sense to exit with an error status. But if the migration does exist and has already been run, I think it would make sense for the app to simply say "migration already applied" and exit with a success status. If the migration is already applied, the goal of running the command is already accomplished, so it isn't an error right?
This seems to be the logic that works for up
... if you're already at the latest migration, then it simply does nothing and exits with a success status. I'm thinking this logic should be extended to running with --only
as well.
LMK what you think.
This makes sense. You could include this fix in your PR as well if you can manage to do it :)
btw. I've updated many things in 1.5.3, so please remember to pull before you start implementing it
Failing test for this issue
https://github.com/sheerun/knex-migrate/compare/master...chadxz:failing-test-%2318?expand=1
Given this project is knex bindings + cli on top of umzug, not sure if the change should go here or there. Will keep looking.
knex-migrate pretty much just calls out to umzug with the name of the migration specified in --only %migration%
. In umzug they explicitly check for the migration to be pending and fail with the error message indicated in the failing test. I opened an issue there to see what they think about making the change.
If they won’t change it we could catch and ignore this error maybe
On Tue, 27 Mar 2018 at 01:31, Chad McElligott [email protected] wrote:
knex-migrate pretty much just calls out to umzug with the name of the migration specified in --only %migration%. In umzug they explicitly check for the migration to be pending and fail with the error message indicated in the failing test. I opened an issue there to see what they think about making the change.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/sheerun/knex-migrate/issues/18#issuecomment-376345679, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR2DUUgbfDpm5MpZ1TqpeyVj0p8rzewks5tiXphgaJpZM4SuFni .
Related Umzug issue: https://github.com/sequelize/umzug/issues/167