BigBinary Blog

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

Database tasks can skip test database using SKIP_TEST_DATABASE

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

1
2> bundle exec rake db:create
3Created database 'app_name_development'
4Created database 'app_name_test'
5

With the environment variable

1
2> SKIP_TEST_DATABASE=true bundle exec rake db:create
3Created database 'app_name_development'
4

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.

Sandip Mane in Rails 6.1
October 27, 2020
Share

Subscribe to our newsletter