Back to Blog
DatabaseMigrationsPrismaDevOps

Database Migrations: Safe Schema Evolution Patterns

Manage database schema changes safely. Learn migration strategies, zero-downtime deployments, and rollback patterns.

B
Bootspring Team
Engineering
February 26, 2026
1 min read

Database migrations are critical for evolving your schema while maintaining data integrity. This guide covers strategies for safe, reversible schema changes.

Expand and Contract Pattern#

For renaming columns safely:

1-- Step 1: Add new column 2ALTER TABLE users ADD COLUMN full_name VARCHAR(255); 3 4-- Step 2: Backfill data 5UPDATE users SET full_name = name; 6 7-- Step 3: Deploy app that writes to both 8-- Step 4: Deploy app that reads from new column 9-- Step 5: Remove old column 10ALTER TABLE users DROP COLUMN name;

Adding NOT NULL Columns#

1-- Step 1: Add nullable 2ALTER TABLE users ADD COLUMN status VARCHAR(20); 3 4-- Step 2: Backfill 5UPDATE users SET status = 'active' WHERE status IS NULL; 6 7-- Step 3: Add constraint 8ALTER TABLE users ALTER COLUMN status SET NOT NULL;

Non-Blocking Index Creation#

CREATE INDEX CONCURRENTLY idx_users_email ON users(email);

Prisma Migrations#

npx prisma migrate dev --name add_status_column npx prisma migrate deploy # Production

Keep migrations small, reversible, and test with production-like data.

Share this article

Help spread the word about Bootspring