Join GitHub today
Fix `bin/rails db:migrate` with specified `VERSION` #30714
Related to #30707
referenced this pull request
Sep 27, 2017
I think this is fine as a bandaid fix, but I'm not sure whether this is a good long term solution. Think about this usecase:
I worry that this PR instead will completely block migrations without a clear path forward causing a lot of friction in the migration process.
Currently, if run
$ rails db:migrate:status Status Migration ID Migration Name -------------------------------------------------- up 20171005143525 One up 20171005143538 Two up 20171005143556 Three $ rails db:migrate VERSION=1 rails aborted! ActiveRecord::UnknownMigrationVersionError: No migration with version number 1. # There is bug $ rails db:migrate VERSION=-1 ubuntu@ubuntu-xenial:/active_projects/zz$ rails db:migrate VERSION=-1 == 20171005143556 Three: reverting ============================================ == 20171005143556 Three: reverted (0.4047s) =================================== == 20171005143538 Two: reverting ============================================== == 20171005143538 Two: reverted (0.0000s) ===================================== == 20171005143525 One: reverting ============================================== == 20171005143525 One: reverted (0.0000s) =====================================
$ rails db:migrate:status Status Migration ID Migration Name -------------------------------------------------- up 20171005143525 One up 20171005143538 Two up 20171005143556 Three $ rails db:migrate VERSION=1 rails aborted! ActiveRecord::UnknownMigrationVersionError: No migration with version number 1. # Fixed $ rails db:migrate VERSION=-1 rails aborted!
About the case:
I think the main reason of the problem in common name of environment variable that we use
What do you think about deprecation of using
Can we validate the supplied version before we call
Renaming the variable is not appropriate: unlike the others you mentioned, it's intended to be set on the rake command line; the others are intended to suitable for setting more globally across a session. (And I believe that's the stronger convention in general: the more broadly a variable is visible, the more specifically it should be named.) Naming such a redundant variable on a
It would also be an unnecessary stopgap: the ability to pass proper arguments to commands, instead of using ugly env vars, is a large motivation for our ongoing effort to convert rake-based commands to thor. Once we've done
We've been using
If someone does have
I haven't checked, but I assume they can run the command with
@matthewd I think I got your point. I just added the changes that check VERSION.
This PR shouldn't break our current implementation that we have and AIUI we can apply new strict behavior(See #30714 (comment)).
Could you please review and provide feedback about behavior that this PR provides?
If this behavior doesn't fit, I'll try to find another implementation
Thank you for the response!