Deploying Prisma Applications
1. Deploying to Vercel
| Step | Detail |
| Build cmd | prisma generate && next build |
| Pool | Use Accelerate or pooled URL |
| Edge | Driver adapters or Accelerate |
2. Deploying to AWS Lambda
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-3.0.x"]
}
| Concern | Detail |
| Binary target | Match Lambda OS |
| Bundle size | Include only needed engine |
| Connections | Use RDS Proxy or Accelerate |
3. Deploying with Docker
FROM node:20-alpine
WORKDIR /app
COPY package*.json prisma ./
RUN npm ci && npx prisma generate
COPY . .
CMD ["sh","-c","npx prisma migrate deploy && node dist/server.js"]
| Aspect | Detail |
| linux-musl | Alpine binary target |
| Multi-stage | Smaller final image |
4. Configuring Production Database
| Setting | Detail |
| SSL | ?sslmode=require |
| Pool limit | Set per app replica |
| Statement timeout | Cap long queries |
5. Running Migrations in Production
npx prisma migrate deploy
| Step | Detail |
| deploy ≠ dev | No prompts, no shadow DB |
| Order | Migrate before app start |
| Idempotent | Safe to re-run |
6. Implementing CI/CD Pipeline
| Stage | Tasks |
| CI | format, validate, generate, test, migrate dev (shadow) |
| CD | migrate deploy, build, deploy |
| Gates | Approval before prod migrate |
7. Managing Multiple Environments
| Env | DB |
| dev | Local Docker |
| preview | Branch DB (Neon/PlanetScale) |
| staging | Replica of prod schema |
| prod | Production cluster |
8. Implementing Zero-Downtime Migrations
- Add new column nullable / new table — deploy
- Backfill data — async job
- Switch reads/writes to new column
- Drop old column — deploy
| Rule | Detail |
| Expand → contract | Multi-step destructive changes |
| Avoid in one deploy | Rename or drop with code change |
9. Using Database Backups
| Type | Detail |
| PITR | Continuous WAL archiving |
| Snapshots | Daily managed snapshots |
| Test restore | Quarterly disaster drill |
10. Implementing Rollback Strategy
| Approach | Detail |
| App rollback | Redeploy prior image; keep DB forward-compatible |
| DB rollback | Forward-fix migration (preferred over down) |
| Snapshot restore | Last resort, accepts data loss |