August 12, 2020
This blog is part of our Rails 6.1 series.
Rails 6.1 adds support to handle db:rollback
in case of multiple database
application.
Prior to this change, on executing db:rollback
Rails used to rollback the
latest migration from the primary database. If we passed on a [:NAME]
option
along with to specify the database, we used to get an error. Check out the
issue for more details.
> rails db:rollback:secondary
rails aborted!
Don't know how to build task `db:rollback:secondary` (See the list of available tasks with `rails --tasks`)
Did you mean? db:rollback
Staring with Rails 6.1, we need to pass the database name along with
db:rollback:[NAME]
otherwise a RuntimeError
is raised.
> rails db:rollback
rails aborted!
You're using a multiple database application. To use `db:migrate:rollback` you must run the namespaced task with a VERSION. Available tasks are db:migrate:rollback:primary and db:migrate:rollback:secondary.
> rails db:rollback:primary
== 20200731130500 CreateTeams: reverting ======================================
-- drop_table(:teams)
-> 0.0060s
== 20200731130500 CreateTeams: reverted (0.0104s) =============================
Check out the pull request for more details on this.
If this blog was helpful, check out our full blog archive.