Multiple Databases with Rails
Out of the box, Rails 8 ships with a config/database.yml that has 4 databases:
- primary
 
- queue
 
- cache
 
- cable
 
SQLite
For SQLite, you don't have to do a thing! Your app's config/database.yml defines the path to where these SQLite databases are stored on disk. By default, they'll point to storage/db-name.sqlite. This directory is symlinked every deploy so each release has access to the databases.
PostgreSQL and MySQL
For Postgres and MySQL, you'll need to define a DATABASE_URL for each database in your config/database.yml.
- DATABASE_URL (or PRIMARY_DATABASE_URL)
 
- QUEUE_DATABASE_URL (for Solid Queue)
 
- CACHE_DATABASE_URL (for Solid Cache)
 
- CABLE_DATABASE_URL (for Solid Cable)
 
When you attach a database to an app in Hatchbox, it tries to set DATABASE_URL. If it's already defined, it will prefix a color like BLUE_DATABASE_URL so it doesn't conflict. You can rename these environment variables so you have one for each database.