rails/railties
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
..
bin Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
exe Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
lib Merge pull request #41441 from jonathanhefner/apidocs-inline-code-markup 2021-02-15 11:16:44 -06:00
test Guard against using VERSION with db:rollback (#41430) 2021-02-15 19:30:05 -05:00
.gitignore Install JavaScript packages before run test 2019-02-11 09:58:08 +09:00
CHANGELOG.md Avoid footguns in `rails app:update` 2021-02-09 12:20:56 -07:00
MIT-LICENSE Bump license years to 2021 [ci skip] 2021-01-01 12:21:20 +09:00
RDOC_MAIN.rdoc remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
README.rdoc Rename master to main in all code references 2021-01-19 20:46:33 +00:00
Rakefile Fallback to spawn instead of fork in jruby (#36111) 2019-04-26 17:22:28 -05:00
railties.gemspec Rails 7 requires Ruby 2.7 and prefer Ruby 3+ 2021-02-04 16:34:53 +00:00

README.rdoc

= Railties -- Gluing the Engine to the Rails

Railties is responsible for gluing all frameworks together. Overall, it:

* handles the bootstrapping process for a Rails application;

* manages the +rails+ command line interface;

* and provides the Rails generators core.


== Download

The latest version of Railties can be installed with RubyGems:

* gem install railties

Source code can be downloaded as part of the Rails project on GitHub

* https://github.com/rails/rails/tree/main/railties

== License

Railties is released under the MIT license:

* https://opensource.org/licenses/MIT

== Support

API documentation is at

* https://api.rubyonrails.org

Bug reports can be filed for the Ruby on Rails project here:

* https://github.com/rails/rails/issues

Feature requests should be discussed on the rails-core mailing list here:

* https://discuss.rubyonrails.org/c/rubyonrails-core