Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Advertise multi-database support in docs (#13604)
Damian Legawiec33aa5a12fce0
diff --git a/docs/developer/advanced/adding_spree_to_rails_app.mdx b/docs/developer/advanced/adding_spree_to_rails_app.mdxindex 4c3638c1b4..c75611190c 100644--- a/docs/developer/advanced/adding_spree_to_rails_app.mdx+++ b/docs/developer/advanced/adding_spree_to_rails_app.mdx@@ -11,6 +11,10 @@ description: This guide will show you how to add Spree to an existing Ruby on RaIf you already have a Ruby on Rails application, you can add Spree to it by following these steps.+<Info>+ Spree works with **PostgreSQL**, **MySQL**, and **SQLite** — whatever database your Rails app already uses. No database migration is needed.+</Info>+## 1. Add Spree gemsAdd these lines to your project `Gemfile`:diff --git a/docs/developer/core-concepts/architecture.mdx b/docs/developer/core-concepts/architecture.mdxindex 043c67795f..b54b79a99d 100644--- a/docs/developer/core-concepts/architecture.mdx+++ b/docs/developer/core-concepts/architecture.mdx@@ -3,6 +3,19 @@ title: Architecturedescription: Understand how Spree's core models and systems work together---+## System Requirements++| Component | Requirement |+|-----------|-------------|+| **Ruby** | 3.2 or later |+| **Rails** | 7.2 or later |+| **Database** | PostgreSQL, MySQL, or SQLite |+| **Image Processing** | libvips |++<Info>+ Spree works with any database supported by Rails. PostgreSQL and MySQL are recommended for production. SQLite is great for development and small-scale deployments. [Learn more about database configuration](/developer/deployment/database).+</Info>+## OverviewSpree is built around a set of interconnected models that represent the core concepts of e-commerce: products, orders, payments, and shipments. Understanding how these pieces fit together is essential for customizing and extending Spree.diff --git a/docs/developer/deployment/database.mdx b/docs/developer/deployment/database.mdxnew file mode 100644index 0000000000..8279c3a48f--- /dev/null+++ b/docs/developer/deployment/database.mdx@@ -0,0 +1,156 @@+---+title: Database Configuration+description: Learn how to configure Spree to work with PostgreSQL, MySQL, or SQLite.+---++Spree works with all major relational databases supported by Ruby on Rails. You can choose the database that best fits your needs.++## 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 the `DATABASE_URL` environment variable:++```bash+# PostgreSQL+DATABASE_URL=postgres://user:pass@localhost:5432/spree++# MySQL+DATABASE_URL=mysql2://user:pass@localhost:3306/spree++# SQLite+DATABASE_URL=sqlite3:db/production.sqlite3+```++### Using database.yml++You can also configure the database in `config/database.yml`:++<Tabs>+ <Tab title="PostgreSQL">+ ```yaml+ default: &default+ adapter: postgresql+ encoding: unicode+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>++ development:+ <<: *default+ database: spree_development++ production:+ <<: *default+ database: spree_production+ url: <%= ENV["DATABASE_URL"] %>+ ```+ </Tab>+ <Tab title="MySQL">+ ```yaml+ default: &default+ adapter: mysql2+ encoding: utf8mb4+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>++ development:+ <<: *default+ database: spree_development++ production:+ <<: *default+ database: spree_production+ url: <%= ENV["DATABASE_URL"] %>+ ```+ </Tab>+ <Tab title="SQLite">+ ```yaml+ default: &default+ adapter: sqlite3+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>+ timeout: 5000++ development:+ <<: *default+ database: db/development.sqlite3++ production:+ <<: *default+ database: db/production.sqlite3+ ```+ </Tab>+</Tabs>++## Switching Databases++The easiest way to switch your existing Spree application to a different database is using the built-in Rails command:++```bash+# Switch to PostgreSQL+bin/rails db:system:change --to=postgresql++# Switch to MySQL+bin/rails db:system:change --to=mysql++# Switch to SQLite+bin/rails db:system:change --to=sqlite3+```++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:++ ```bash+ bundle install+ ```++2. Create the new database and run migrations:++ ```bash+ bin/rails db:create db:migrate+ ```++3. Optionally load sample data:++ ```bash+ bin/rails spree_sample:load+ ```++## 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`:++```bash+# PostgreSQL+rails new my_store -d postgresql -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb++# MySQL+rails new my_store -d mysql -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb++# SQLite (default, no flag needed)+rails new my_store -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb+```++## 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 | — |++Set the `DATABASE_URL` environment variable to the connection string provided by your cloud provider.diff --git a/docs/developer/deployment/docker.mdx b/docs/developer/deployment/docker.mdxindex 2c5bdffc37..f99b8cbd20 100644--- a/docs/developer/deployment/docker.mdx+++ b/docs/developer/deployment/docker.mdx@@ -7,7 +7,7 @@ Spree (when using Spree Starter template) comes with a Dockerfile that can be usYou can find the Dockerfile in the [Dockerfile](https://github.com/spree/spree_starter/blob/main/Dockerfile) file in the root of the project or in the Spree Starter repository.-This Dockerfile is pre-configured to run Spree with PostgreSQL database and Redis 7.0+ (or Valkey). That's the only external dependency you need to have installed on your machine to be able to run Spree.+This Dockerfile is pre-configured to run Spree with a PostgreSQL database by default. You can also use MySQL or SQLite by changing the `DATABASE_URL` environment variable. [Learn more about database configuration](/developer/deployment/database).You can later use that image to run your application in a containerized environment eg. AWS ECS, AWS Fargate, Azure Container Instances, etc.@@ -27,7 +27,7 @@ You will need to supply the following environment variables to run the container| Variable | Description | Example || --- | --- | --- |-| `DATABASE_URL` | Database URL, this could be your AWS RDS instance or any other PostgreSQL instance | `postgres://user:pass@localhost:5432/spree` |+| `DATABASE_URL` | Database connection URL. Spree supports PostgreSQL, MySQL, and SQLite | `postgres://user:pass@localhost:5432/spree` || `REDIS_URL` | Redis/Valkey URL, used for background jobs processing,this could be your AWS ElastiCache instance or any other Redis/Valkey instance | `redis://localhost:6379/0` || `SECRET_KEY_BASE` | You can generate this by running `bin/rails secret` | `2fad5c0b79d25e4765d3018d8c740f8c3a665f0e5c...` |diff --git a/docs/developer/deployment/environment_variables.mdx b/docs/developer/deployment/environment_variables.mdxindex e7f1d7caa7..30b7d3a47d 100644--- a/docs/developer/deployment/environment_variables.mdx+++ b/docs/developer/deployment/environment_variables.mdx@@ -10,10 +10,22 @@ This variables are required to run Spree Starter.| Variable | Description | Example || --- | --- | --- |-| `DATABASE_URL` | Database URL, this could be your AWS RDS instance or any other PostgreSQL instance | `postgres://user:pass@localhost:5432/spree` |+| `DATABASE_URL` | Database connection URL. Spree supports PostgreSQL, MySQL, and SQLite | `postgres://user:pass@localhost:5432/spree` || `REDIS_URL` | Redis/Valkey URL, used for background jobs processing,this could be your AWS ElastiCache instance or any other Redis/Valkey instance | `redis://localhost:6379/0` || `SECRET_KEY_BASE` | You can generate this by running `bin/rails secret` | `2fad5c0b79d25e4765d3018d8c740f8c3a665f0e5c...` |+### Database URL examples++Spree supports PostgreSQL, MySQL, and SQLite. Set the `DATABASE_URL` according to your database:++| Database | Example |+|----------|---------|+| PostgreSQL | `postgres://user:pass@localhost:5432/spree` |+| MySQL | `mysql2://user:pass@localhost:3306/spree` |+| SQLite | `sqlite3:db/production.sqlite3` |++[Learn more about database configuration](/developer/deployment/database).+## Optional environment variablesThere are also some other environment variables that you can set to customize your Spree application.diff --git a/docs/developer/getting-started/quickstart.mdx b/docs/developer/getting-started/quickstart.mdxindex bd4108452b..8241ae3a49 100644--- a/docs/developer/getting-started/quickstart.mdx+++ b/docs/developer/getting-started/quickstart.mdx@@ -6,6 +6,10 @@ description: "Start building awesome eCommerce applications with Spree open-sourFollow the instructions below to learn how to build and deploy your Spree Commerce store.+<Info>+ Spree works with **PostgreSQL**, **MySQL**, and **SQLite** databases. The installer defaults to SQLite for quick setup. You can switch to PostgreSQL or MySQL at any time by updating your `database.yml` or `DATABASE_URL` environment variable. [Learn more about database configuration](/developer/deployment/database).+</Info>+## 1. Installing Spree<Tabs>@@ -51,6 +55,11 @@ Follow the instructions below to learn how to build and deploy your Spree Commer```bashrails new my_store -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb```+ To use a specific database, pass the `-d` flag:+ ```bash+ rails new my_store -d postgresql -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb+ rails new my_store -d mysql -m https://raw.githubusercontent.com/spree/spree/main/backend/template.rb+ ```5. Navigate to the application directory```bashcd my_storediff --git a/docs/docs.json b/docs/docs.jsonindex a999ba4741..7919996bf5 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -208,6 +208,7 @@"group": "Deployment","icon": "server","pages": [+ "developer/deployment/database","developer/deployment/render","developer/deployment/aws","developer/deployment/docker",