Provision a PostgreSQL database

5 min readUpdated April 2026

StackBlaze managed PostgreSQL runs as a dedicated instance with its own persistent storage. Your data keeps a stable identity across restarts, so it survives pod rescheduling, node failures, and platform upgrades.

The database is never exposed to the public internet. It gets a stable internal hostname that your app resolves automatically on your project’s private network.

Architecture

Single instance
TCP:5432mount
App Service

DATABASE_URL

injected as secret

PostgreSQL
PostgreSQL

mydb-postgres

managed instance

PVC Storage

/var/lib/postgresql

PersistentVolumeClaim

Auto-injected connection string

.env (injected)

# Automatically set when you attach the database

DATABASE_URL=postgresql://sb_user:s3cr3tP4ss!@mydb-postgres:5432/mydb

# The hostname resolves on your project's private network

# Only accessible from within your project

Running migrations

Prisma migration deploy

$ npx prisma migrate deploy

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "mydb"

                        at mydb-postgres:5432

3 migrations found in prisma/migrations

20240101000000_init

20240215000000_add_users_table

20240310000000_add_posts_index

All migrations have been applied

Under the hood

  • Dedicated instance — your database gets a stable hostname and keeps its storage across restarts. A replacement is never brought up until the original terminates cleanly, preventing split-brain.
  • Persistent storage — backed by network block storage that outlives the pod. You can restart or reschedule the instance without losing data.
  • Stable internal hostname: the add-on keeps the same private-network address across restarts and rescheduling, so your app never has to be reconfigured.
  • Backups & recovery: StackBlaze continuously archives write-ahead logs and takes scheduled base backups, so you can take on-demand snapshots or restore to a point in time. See the point-in-time recovery guide.

Step by step

01

Add a PostgreSQL add-on

From your app, open Add-ons and provision PostgreSQL. Choose a version (15, 16, or 17), storage size, and a plan. StackBlaze provisions a dedicated managed instance with persistent storage in seconds.

02

Attach it to your app

Attaching the add-on injects DATABASE_URL into your app automatically. The connection points at the add-on's internal hostname, which resolves on your project's private network, no public exposure and no manual wiring.

03

Run your migrations

Trigger a deploy and use a start command that runs migrations before starting the server, or run them manually via the StackBlaze CLI. For Prisma, use "npx prisma migrate deploy". For Django, "python manage.py migrate". Both connect using DATABASE_URL automatically.

04

Query in production

Your service connects to Postgres over the internal cluster network. No public internet exposure, no firewall rules to configure. The connection string includes a random password generated at provision time and rotated when you trigger a credential rotation from the dashboard.