Add a Database
Blossom runs managed PostgreSQL, MySQL, MariaDB and MongoDB, with backups on from the start. Ask your agent:
Add a PostgreSQL database for my-app.
Here are the steps it takes, using the App from Getting Started. Keep the same profile Location so the database runs alongside your App, on Blossom Cloud or your own cloud.
Create The Database
blossom database_instance:init
database_instance.yml:
database_instance:
name: production
engine: postgres # postgres, mysql, mariadb, or mongodb
availability: shared # or dedicated, its own Server
storage_gib: 20 # grows online later, never shrinks
backup_storage_id: blossom_cloud
database_name: app_production
# ...
blossom database_instance:create --data database_instance.yml --follow
| Shared | Dedicated | |
|---|---|---|
| Runs on | Capacity shared with your other data | Its own Server |
| Good for | Getting started, small Apps | Production, with an optional standby |
Connect It To Your App
In the UI, open your Environment’s Variables and Links → Manage connections. Connected data shows what is connected and what is available in the same Location. Choose Connect, check the variable name, and confirm. You can also start from a Database or Cache page with Connect to Environment. Creating a database first and connecting it later works too.
PostgreSQL creates the initial app_production database with the instance.
Find its ID, then link that Database to the Environment:
blossom database:list --database_instance database_instance-100
blossom environment_link:init
Edit environment_link.yml to use the Database ID from the list:
environment_link:
environment_id: environment-100 # replace with your environment id
target_type: Database
target_id: database-100
var_name: DATABASE_URL
blossom environment_link:create --data environment_link.yml
Every Service receives DATABASE_URL on its next deploy. Configure your
App’s PostgreSQL driver to read that variable and run its migrations in the
Release Phase.
The Sinatra starter runs without a database; linking PostgreSQL makes it
available for the features you add.
What You Get
- A running database, reachable from linked Environments over private networking
DATABASE_URLin every Service of the Environment- Backups from the start, with restore when you need it
Next, deploy your App to use the connection.
Keep Prompting
Add a feature that saves data to PostgreSQL using DATABASE_URL.
See Databases and Caches for other engines and connection options.