As a developer, we use multiple databases very often. It would be very helpful if we could reset one particular database at a time.
Rails 7 have introduced database-specific tasks for setup and reset under each namespace. We can now reset any specific database. Before this change, we didn’t have the option to perform these tasks on specific databases.
The default setup and reset tasks remain unchanged, and they would work the same as before.
Let’s say we have two databases,
secondary in our Rails application.
rails db:reset and
rails db:setup are the rake tasks to reset and setup databases.
These tasks apply to all the databases present in the application.
There was no task to reset or setup any particular database. If we try to reset or setup any particular database, it would throw an error.
After the changes in Rails 7, we can reset or setup the particular database we want.
db:seed that is part of the setup would not seed a specific database.
db:seed didn’t behave in the same line as other tasks.