Back to BlogWeb Development

Running Prisma Migrations Safely in Production

Expand-contract patterns, backups, and deploy ordering when applying Prisma schema changes live.

Migration risk

Schema changes can lock tables or rewrite data unexpectedly. Prisma migrate deploy applies pending SQL against production databases during release windows.

Vcom Web Tech takes backups immediately before migrations and verifies rollback paths for destructive changes.

Long-running migrations may need online schema change tools at scale beyond single VPS PostgreSQL.

Expand and contract

Add nullable columns before backfilling data, then enforce NOT NULL in a later release. Removing columns follows the reverse: stop writing, deploy code without references, then drop column.

This pattern keeps old app versions compatible during rolling deploys.

Document multi-step migrations in tickets so no engineer skips a phase.

CI integration

Generate migrations in development, review SQL in pull requests, and apply on staging with production-like data volume when possible.

Fail deploys if migrate exit code is non-zero.

Never edit applied migration history on production without extreme care.

Observability

Watch database CPU and lock waits during migrations. Pause traffic-heavy jobs if needed.

Alert on migration duration anomalies compared to historical deploys.

Post-deploy verify critical queries still use expected indexes.

Additional operational notes

Operational excellence on Linux hosting requires documenting every change to Nginx, systemd, PM2, Docker, and DNS in a runbook your team shares. Vcom Web Tech clients benefit when staging environments mirror production firewall rules, TLS versions, and mail authentication so surprises appear before customers notice. Schedule quarterly reviews of backups, certificate expiry, DMARC reports, and monitoring alerts even when traffic feels stable.

When incidents occur, capture timelines and root causes in blameless postmortems. Patterns from past 502 errors, failed renewals, or bounce spikes inform checklists for the next deployment. Training new team members on SSH access, log locations, and escalation paths reduces dependency on single maintainers.

Security patches, dependency upgrades, and framework migrations should ride the same CI pipelines that deploy application code. Automate smoke tests that hit health endpoints and send test mail through staging SMTP relays. Small consistent investments beat heroic firefighting during launch weekends.

Capacity planning matters on VPS hosts where vertical scaling has limits. Watch disk inode usage, connection counts, and database connection pools as traffic grows. Proactive upgrades cost less than emergency migrations during peak sales or campaign sends.

Finally, communicate with stakeholders using plain language about risk, downtime windows, and deliverability metrics. Technical depth supports trust when email authentication or deployment strategy changes affect revenue-facing systems.

Additional operational notes

Operational excellence on Linux hosting requires documenting every change to Nginx, systemd, PM2, Docker, and DNS in a runbook your team shares. Vcom Web Tech clients benefit when staging environments mirror production firewall rules, TLS versions, and mail authentication so surprises appear before customers notice. Schedule quarterly reviews of backups, certificate expiry, DMARC reports, and monitoring alerts even when traffic feels stable.

When incidents occur, capture timelines and root causes in blameless postmortems. Patterns from past 502 errors, failed renewals, or bounce spikes inform checklists for the next deployment. Training new team members on SSH access, log locations, and escalation paths reduces dependency on single maintainers.

Security patches, dependency upgrades, and framework migrations should ride the same CI pipelines that deploy application code. Automate smoke tests that hit health endpoints and send test mail through staging SMTP relays. Small consistent investments beat heroic firefighting during launch weekends.

Capacity planning matters on VPS hosts where vertical scaling has limits. Watch disk inode usage, connection counts, and database connection pools as traffic grows. Proactive upgrades cost less than emergency migrations during peak sales or campaign sends.

Finally, communicate with stakeholders using plain language about risk, downtime windows, and deliverability metrics. Technical depth supports trust when email authentication or deployment strategy changes affect revenue-facing systems.