1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/application/rake
Nick Borromeo 0f09dfca36
Guard against using VERSION with db:rollback (#41430)
* Guard against using VERSION with db:rollback

I recently ran a migration that I needed to rollback, and admittedly, I often forget the proper incantation for this 😅
so the first thing I tried was to run `bin/rake db:rollback VERSION=123454679`. I had hoped that this reverted my
migration back and at first glance I thought it worked. However on closer inspection I realized that it was a different
migration, which initially confused me.

So I looked over the docs and saw that I was using the rake task incorrectly, and promptly corrected my mistake.

Proposal

Looking at the how the `:down` task is defined we see

8dc7439058/activerecord/lib/active_record/railties/databases.rake (L206-L211)

This got me thinking that maybe it would be helpful to have the opposite of this guard defined in `rollback` so that if
`VERSION` is passed it will raise an exception instead of just negecting the extra argument. This could help the user
realize that something went wrong instead of just seeing output and assuming that the rollback happened.

Change

We now raise an execption if `VERSION` is passed when attempting to rollback a migration

* update test name and fix failing test

* remove byebug

[Nick Borromeo + Kate Travers + Rafael Mendonça França]
2021-02-15 19:30:05 -05:00
..
dbs_test.rb Rails 6.2 is now Rails 7.0 2021-02-04 16:47:16 +00:00
framework_test.rb Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
log_test.rb Revert "Avoid chdir error in Railties tests on Ruby master" 2020-12-26 15:01:24 +09:00
migrations_test.rb Guard against using VERSION with db:rollback (#41430) 2021-02-15 19:30:05 -05:00
multi_dbs_test.rb Rails 6.2 is now Rails 7.0 2021-02-04 16:47:16 +00:00
restart_test.rb Revert "Avoid chdir error in Railties tests on Ruby master" 2020-12-26 15:01:24 +09:00
tmp_test.rb Revert "Avoid chdir error in Railties tests on Ruby master" 2020-12-26 15:01:24 +09:00