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.
| Feature | Details |
|---|---|
| Supported Engines | PostgreSQL, MariaDB, MongoDB |
| Regions | US, EU, APAC, LATAM |
| Storage Limit | 1 GB soft limit per database |
| Backups | Daily at 3 AM UTC, 7-day retention |
| Pricing | $5 per database/month (add-on) |
| Availability | Individual and Business plans |
Creating a Database
- Go to Dashboard → Databases
- Click Create Database
- Enter a name (lowercase, alphanumeric, hyphens allowed)
- Select the database engine: PostgreSQL, MariaDB, or MongoDB
- Choose a region
- 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):
| Variable | Example Value |
|---|---|
DB_NAME_HOST | db.us.prev.sh |
DB_NAME_PORT | 5432 |
DB_NAME_NAME | prev_a1b2c3_mypostgres |
DB_NAME_USER | prev_a1b2c3_mypostgres |
DB_NAME_PASSWORD | (auto-generated) |
DB_NAME_TYPE | postgresql |
DB_NAME_URL | postgresql://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→ prefixDB_MYPOSTGRES_ - Database name
my-mongo→ prefixDB_MY_MONGO_ - Database name
app-db→ prefixDB_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:
- Go to Dashboard → Templates
- Edit or create a template
- In the Databases field, enter database names (comma-separated)
- 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_dumpcompressed backups - MariaDB:
mysqldumpcompressed backups - MongoDB:
mongodumpcompressed 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.
| Region | Identifier | DB Host |
|---|---|---|
| United States | us | db.us.prev.sh |
| Europe | eu | db.eu.prev.sh |
| Asia-Pacific | apac | db.apac.prev.sh |
| Latin America | latam | db.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:
- Go to Dashboard → Databases
- Click the database you want to delete
- Click Delete Database
- 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.