---
title: "Database tasks can skip test database using SKIP_TEST_DATABASE"
description:
  "Rails 6.1 adds ability to skip modifying test database in database tasks with
  an environment variable."
canonical_url: "https://www.bigbinary.com/blog/database-tasks-can-skip_test_database-with-an-environment-variable"
markdown_url: "https://www.bigbinary.com/blog/database-tasks-can-skip_test_database-with-an-environment-variable.md"
---

# Database tasks can skip test database using SKIP_TEST_DATABASE

Rails 6.1 adds ability to skip modifying test database in database tasks with an
environment variable.

- Author: Sandip Mane
- Published: October 27, 2020
- Categories: Rails 6.1, Rails

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

## Without the environment variable

```bash

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

```

## With the environment variable

```bash

> 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](https://github.com/rails/rails/commit/6ca9031ba3c389f71366c3e6abf069c6924c5acf).
Hence the need for an environment variable to skip `test` database creation.

Check out the [pull request](https://github.com/rails/rails/pull/39027) for more
details.

## Links

- [Human page](https://www.bigbinary.com/blog/database-tasks-can-skip_test_database-with-an-environment-variable)
