How to Manage Databases in App Platform

Create a Database

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab. Add a database component by clicking the Create Component button and choosing the Database option.

Component screen

Select your database configuration, choosing from the available engines and plans. You can add a dev database or an existing managed database from your DigitalOcean account. When you're ready to proceed, click Create and Attach to confirm your choices.

Database creation screen

Connect to a Database

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab.

Click on your database to view its details. The connection information for your database is provided under the Connection Details heading.

Database detail screen

The full connection string for your database will also be available as a runtime environment variable named DATABASE_URL which you can use in your application code. You should see this it in the details for your service component, set to a value such as:

postgres://${db.USERNAME}:${db.PASSWORD}@${db.HOSTNAME}:${db.PORT}/${db.DATABASE}

As you can see, DATABASE_URL is in fact wrapping several environment variables that you can also access individually, such as db.USERNAME, db.PASSWORD, etc.

Upgrade Dev Database to Managed Database

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab.

Click the dev database you would like to upgrade to a managed database. You can choose the size of the machines that run your database with the Node Plan drop-down, and add standby nodes that stay synchronized and provide failover during downtime with the Standby Nodes drop-down.

Click Upgrade Database to complete the process.

Destroy a Database

Go to https://cloud.digitalocean.com/apps, click on your app, and click on the Components tab.

Click on your database. The details screen for your database features a Destroy Database button on the bottom that will destroy your database after you confirm the action.

A component in App Platform is any deployable, billable, run-time software element in your app. A component can be a database, a service, a worker, or a static site.
Existing databases are instances of a DigitalOcean managed database created outside of App Platform for production use.
Create and configure a static site in App Platform
Create and configure background workers in App Platform
A review of your data storage options in App Platform
Create and configure services in App Platform