Managed Databases let you provision real database instances and attach them to preview environments with a single CLI flag. No connection strings to copy, no manual setup — prev handles provisioning, credentials, and cleanup.

Overview

Each managed database runs on a dedicated regional VM with PostgreSQL, MariaDB, and MongoDB pre-installed. When you create a database through the Dashboard, prev provisions it on the closest regional server and generates unique credentials for your account.

FeatureDetails
Supported EnginesPostgreSQL, MariaDB, MongoDB
RegionsUS, EU, APAC, LATAM
Storage Limit1 GB soft limit per database
BackupsDaily at 3 AM UTC, 7-day retention
Pricing$5 per database/month (add-on)
AvailabilityIndividual and Business plans

Creating a Database

  1. Go to Dashboard → Databases
  2. Click Create Database
  3. Enter a name (lowercase, alphanumeric, hyphens allowed)
  4. Select the database engine: PostgreSQL, MariaDB, or MongoDB
  5. Choose a region
  6. Click Create

Provisioning takes approximately 30 seconds. The database status changes from "creating" to "active" once ready. You can view connection details (host, port, username, password, connection string) on the database detail page.

Attaching Databases to Previews

Use the --db flag when deploying a preview to attach one or more managed databases:

# Attach a single database
prev --db mypostgres .

# Attach multiple databases
prev --db mypostgres --db mymongo .

prev resolves the database credentials at deploy time and injects them as environment variables into your preview container. Your application reads them like any other env var — no SDK or library required.

Environment Variables

For each attached database, prev injects the following environment variables (where NAME is your database name in uppercase, with hyphens replaced by underscores):

VariableExample Value
DB_NAME_HOSTdb.us.prev.sh
DB_NAME_PORT5432
DB_NAME_NAMEprev_a1b2c3_mypostgres
DB_NAME_USERprev_a1b2c3_mypostgres
DB_NAME_PASSWORD(auto-generated)
DB_NAME_TYPEpostgresql
DB_NAME_URLpostgresql://user:pass@host:5432/db

When you attach a single database, prev also sets a convenience alias:

DATABASE_URL=postgresql://user:pass@host:5432/db

This makes it easy to use with frameworks like Rails, Django, Prisma, or any ORM that reads DATABASE_URL by default.

Naming Convention

The environment variable prefix is derived from the database name:

  • Database name mypostgres → prefix DB_MYPOSTGRES_
  • Database name my-mongo → prefix DB_MY_MONGO_
  • Database name app-db → prefix DB_APP_DB_

Using with Deployment Templates

If you use Deployment Templates (Business plan), you can save database attachments as part of the template configuration. When a template specifies databases, every deployment using that template automatically attaches them — no need to pass --db every time.

To configure databases in a template:

  1. Go to Dashboard → Templates
  2. Edit or create a template
  3. In the Databases field, enter database names (comma-separated)
  4. Save the template
# Deploy using a template with pre-configured databases
prev --template my-fullstack-app .

Supported Database Engines

PostgreSQL

The most popular choice for web applications. Compatible with Prisma, TypeORM, Sequelize, Django ORM, ActiveRecord, and virtually every web framework.

  • Default port: 5432
  • Connection string format: postgresql://user:pass@host:5432/dbname

MariaDB

MySQL-compatible engine. Works with any MySQL driver or ORM.

  • Default port: 3306
  • Connection string format: mysql://user:pass@host:3306/dbname

MongoDB

Document database for flexible, schema-less data. Works with Mongoose, the MongoDB Node.js driver, PyMongo, and more.

  • Default port: 27017
  • Connection string format: mongodb://user:pass@host:27017/dbname

Backups

All managed databases are backed up daily at 3:00 AM UTC. Backups are retained for 7 days and stored on the same regional VM.

  • PostgreSQL: pg_dump compressed backups
  • MariaDB: mysqldump compressed backups
  • MongoDB: mongodump compressed backups

Backup restoration is available on request via support.

Regions

Databases are provisioned in the same regions as preview environments. For best performance, create your database in the same region where you deploy previews.

RegionIdentifierDB Host
United Statesusdb.us.prev.sh
Europeeudb.eu.prev.sh
Asia-Pacificapacdb.apac.prev.sh
Latin Americalatamdb.latam.prev.sh

Limits & Pricing

  • $5/month per database (billed as a Paddle add-on)
  • 1 GB soft limit per database — you'll receive a warning when approaching the limit, but the database won't be stopped
  • Available on both Individual and Business plans
  • No limit on the number of databases you can create (each is billed separately)

Deleting a Database

To delete a managed database:

  1. Go to Dashboard → Databases
  2. Click the database you want to delete
  3. Click Delete Database
  4. Confirm the deletion

Warning: Deleting a database permanently destroys all data. This action cannot be undone. Active preview environments attached to the database will lose their database connection.

CI/CD Integration

The --db flag works seamlessly in CI/CD pipelines:

name: PR Preview with Database

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install prev
        run: curl -fsSL https://prev.sh/install.sh | sh

      - name: Deploy Preview
        run: |
          prev --db staging-postgres \
               --subdomain pr-${{ github.event.number }} \
               --ttl 7d \
               .
        env:
          PREV_API_KEY: ${{ secrets.PREV_API_KEY }}

Every pull request gets a live preview with a real database connection. The database persists across preview redeployments, so data isn't lost when code changes are pushed.