Database tasks can skip test database using SKIP_TEST_DATABASE

Sandip Mane

Sandip Mane

October 27, 2020

This blog is part of our  Rails 6.1 series.

In Rails 6.1, Rails will skip modifications to the test database if SKIP_TEST_DATABASE is set to true.

Without the environment variable


> bundle exec rake db:create
Created database 'app_name_development'
Created database 'app_name_test'

With the environment variable


> SKIP_TEST_DATABASE=true bundle exec rake db:create
Created database 'app_name_development'

As we can see in the first example, both a development and a test database were created, which is unexpected when directly invoking db:create. One obvious solution to this problem is to force the development environment to only create a development database. However this solution will break bin/setup as mentioned in this commit. Hence the need for an environment variable to skip test database creation.

Check out the pull request for more details.

If this blog was helpful, check out our full blog archive.

Stay up to date with our blogs.

Subscribe to receive email notifications for new blog posts.