Skip to main content

Supported Databases

Configuring Your Database

Using DATABASE_URL

The simplest way to configure your database is via the DATABASE_URL environment variable:

Using database.yml

You can also configure the database in config/database.yml. The connection pool is sized to cover web request threads plus background job threads, since jobs run inside the web container by default:

Switching Databases

The easiest way to switch your existing Spree application to a different database is using the built-in Rails command:
This command will:
  • Update your Gemfile with the correct database gem
  • Generate a new config/database.yml configured for the selected database
After running the command, complete the switch:
  1. Install the new gem:
  2. Create the new database and run migrations:
  3. Optionally load sample data:

Creating a New App with a Specific Database

When creating a new Spree application with the manual installation method, pass the -d flag to rails new:

Cloud Database Services

For production deployments, you can use managed database services: Set the DATABASE_URL environment variable to the connection string provided by your cloud provider.