Database
The template uses PostgreSQL with Drizzle ORM. Locally it runs in Docker; in production you point it at any managed Postgres.
Local (Docker)
The bundled docker-compose.yml runs Postgres on host port 5432 by default:
docker compose up -dThe DATABASE_URL in .env.example already targets it, so a fresh project works
without changes:
postgresql://stackblaze:stackblaze@localhost:5432/stackblazeIf port 5432 is already in use — commonly by a system-installed Postgres — remap
the container with POSTGRES_PORT and update DATABASE_URL to match:
POSTGRES_PORT=5433 docker compose up -dpostgresql://stackblaze:stackblaze@localhost:5433/stackblazeProduction
Use any managed Postgres — Supabase, Neon, Railway, AWS RDS, Azure, GCP, or a
Vercel Marketplace database. Set DATABASE_URL to its connection string.
Most hosted providers require SSL — append ?sslmode=require to the
connection string if connections are rejected.
Schema management
The schema is defined in lib/db/schema.ts. Two workflows:
| Command | Use |
|---|---|
npm run db:push | Push the schema directly — fast, good for dev and first prod setup. |
npm run db:generate | Generate versioned migration files under drizzle/. |
npm run db:studio | Open Drizzle Studio (a database GUI). |
Auth tables are generated by better-auth. After changing auth config, run
npm run auth:generate (rewrites lib/db/schema.ts) then npm run db:push.
Test database
Integration tests use a separate database (TEST_DATABASE_URL). Create it once
in your Postgres instance:
docker exec stackblaze-postgres psql -U stackblaze -d stackblaze \
-c "CREATE DATABASE stackblaze_test;"