How to Handle Database Migrations
Zero-downtime schema changes - the patterns that dont require a maintenance window.
Database migrations are the operation most likely to cause a production incident. Locking a table during a migration on a busy database can bring an application to its knees in seconds. This guide covers the patterns that allow schema changes without downtime and without a 2am maintenance window.
No fluff. Production-grade answers from engineers who build this every day.
Why Most Migrations Fail in Production
The development environment lie: migrations run fast on a table with 100 rows. On a production table with 10 million rows, the same ALTER TABLE with a default value locks the table for 20 minutes. Your load balancer health check fails. Your application goes down. The core principle: decouple schema changes from code deployment. Schema first, then code, then cleanup. Never in a single atomic deployment.
At Valletta Software, we focus on:
Migration tools: TypeORM migrations Prisma migrate Alembic (Python) Flyway Liquibase - pick one and commit
Up plus down: every migration has a rollback - no irreversible migrations without a tested undo
Zero-downtime ADD COLUMN: add nullable column first - no default value no NOT NULL constraint
Zero-downtime NOT NULL: add nullable then backfill in batches then add NOT NULL plus default
Zero-downtime DROP COLUMN: remove from code first then deploy then drop column in next migration
Index creation: CREATE INDEX CONCURRENTLY (PostgreSQL) - no table lock
Large table changes: pg_repack or gh-ost - online schema change without locking
The Migration Deployment Process
The sequence that prevents the midnight rollback.
We give you more than just people. We give you top performers who drive results.
Write boilerplate and scaffolding 3x faster with AI
Generate tests, migrations, and config automatically
Document architecture decisions as you build
Ship production-grade code - not just demos
How to Handle Database Migrations - With Engineers Who've Survived Production
We've run zero-downtime migrations on tables with hundreds of millions of rows. The patterns are proven.
Our engineers are trained in today's most powerful tools - Copilot, Claude, Cursor, and AI-assisted tooling - and use them daily to move faster without cutting corners.
Choose from a solo dev, mini team, or full squad. All powered by AI and ready to build from day one.
Let's keep it simple.
Our backend engineers apply zero-downtime migration patterns: CONCURRENTLY index creation, nullable-first columns, batch backfills, and tested rollbacks on every schema change.
Need This Done? Don't Build It Alone.
Our engineers have done this before - on real products, under real deadlines.
Free consultation • No commitment required • Response within 24 hours