BigBinary Blog

We write about Ruby on Rails, React.js, React Native, remote work, open source, engineering and design.

Additional database-specific rake tasks for multi-database users

This blog is part of our Rails 6.1 series.

Rails 6.1 provides additional tasks to work with a specific database when working in a multi database setup.

Before Rails 6.1, only the following tasks worked on a specific database.

  • rails db:migrate:primary
  • rails db:create:primary
  • rails db:drop:primary

But some tasks that could be applied to a specific database were missing. Let's checkout an example.

Before Rails 6.1, running a top level migration on a multi-database project, dumped the schema for all the configured databases, but if a database specific migration was run, the schema was not dumped. And there were no tasks to manually dump the schema of a specific database.


> rails db:schema:dump:primary

rails aborted!
Don't know how to build task `db:schema:dump:primary` (See the list of available tasks with `rails --tasks`)
Did you mean? db:schema:dump

Therefore, in Rails 6.1, the following database specific tasks were introduced.

  • rails db:schema:dump:primary
  • rails db:schema:load:primary
  • rails db:test:prepare:primary

Check out the pull request for more details.

Amit Gupta in Rails 6.1
13, 2021
Share

You might also like

Rails 6.1 adds support for PostgreSQL interval data type

Rails 6.1 allows per environment configuration support for Active Storage

Rails 6.1 adds support for belongs_to to has_many inversing

Rails 6.1 adds strict_loading to warn lazy loading associations

Subscribe to our newsletter