Supported Databases
| Database | Development | Production | Notes |
|---|---|---|---|
| PostgreSQL | Yes | Yes | Recommended for production. Best performance for large catalogs and high traffic |
| MySQL | Yes | Yes | Fully supported. A great choice if your team already uses MySQL |
| SQLite | Yes | Yes | Zero-configuration setup. Ideal for development, small stores, and getting started quickly |
Configuring Your Database
Using DATABASE_URL
The simplest way to configure your database is via theDATABASE_URL environment variable:
Using database.yml
You can also configure the database inconfig/database.yml:
- PostgreSQL
- MySQL
- SQLite
Switching Databases
The easiest way to switch your existing Spree application to a different database is using the built-in Rails command:- Update your
Gemfilewith the correct database gem - Generate a new
config/database.ymlconfigured for the selected database
-
Install the new gem:
-
Create the new database and run migrations:
-
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:| Provider | PostgreSQL | MySQL |
|---|---|---|
| AWS | RDS PostgreSQL, Aurora PostgreSQL | RDS MySQL, Aurora MySQL, RDS MariaDB |
| Google Cloud | Cloud SQL for PostgreSQL | Cloud SQL for MySQL |
| Azure | Azure Database for PostgreSQL | Azure Database for MySQL |
| Heroku | Heroku Postgres | JawsDB, ClearDB |
| Render | Render PostgreSQL | — |
DATABASE_URL environment variable to the connection string provided by your cloud provider.
