Yes you can! Rails 8 is out and it can have up to 4 databases, one primary, one for Solid Queue, one for Solid Cache and one for Solid Cable.
Chris has a great video guide on how to set these up in both production and development, in case you want to test things locally before going to production.)
https://gorails.com/episodes/how-to-configure-multiple-databases-with-railsHatchbox connects to a database by using an environment variable with the connection string as the value.
The primary database can use DATABASE_URL, and the others can use either the Hatchbox generated ones (BLUE_DATABASE_URL) or they can be renamed to QUEUE_DATABASE_URL, CACHE_DATABASE_URL and CABLE_DATABASE_URL.
The last piece of the puzzle is to make sure your database.yml has the matching name set as the url attribute like so:
Production:
url: <%= ENV["DATABASE_URL"] %>
Solid Queue:
queue:
url: <%= ENV["QUEUE_DATABASE_URL"] %>
Solid Cache:
cache:
url: <%= ENV["CACHE_DATABASE_URL"] %>
Solid Cable:
cache:
url: <%= ENV["CABLE_DATABASE_URL"] %>
If you want you can use the Hatchbox generated RED_DATABASE_URL or BLUE_DATABASE_URL, just make sure that you match the environment variable with the names you use in your database.yml file in your Rails app.
If you are using the Hatchbox PostgreSQL or MySQL, make sure your server has the appropriate database role and you will see a button to create and add a new database to your app in the app/databases section.
If you are using SQLite, your databases will be stored in the shared storage folder and this will persist and be sym-linked between deploys.
DATABASE_URL=sqlite3:///home/deploy/myapp/storage/production.sqlite3
QUEUE_DATABASE_URL=sqlite3:///home/deploy/myapp/storage/production_queue.sqlite3
(Change "myapp" to the name of your application. Also note that SQLite is a file on your server, so it will only work with a single server.)
Note: You do not have to set up all 4 databases, but if you want to use the new features you will need a separate database for each one. (Although if you just want to try something out or it is a very small app, you can use one database for everything, but the new Rails default will be to use a separate database for each of the new features.)