Database Migration Plan Prompt
Ship a schema change without downtime or data loss — an expand-migrate-contract migration plan with backward compatibility, ordering, and a reversal path.
Overview
A schema change deployed naively locks tables, breaks the running version, or loses data on rollback. This prompt plans a safe migration using the expand/contract pattern: the backward-compatible expand step, the data backfill, the cutover, and the later contract — each ordered so the old and new code can both run during deploy, with a reversal path at every stage.
Why This Works
- Expand/contract keeps both code versions working through the deploy
- Putting drops in a later deploy makes the change reversible when it matters
- Calling out locking steps prevents the migration that takes the site down
Best for
- Schema changes on tables with live traffic and real data
- Deploys where the migration and code ship together
- Large tables where a naive ALTER would lock
Not for
- Designing the schema in the first place — use a database design workflow
- Tuning a slow query — use a SQL optimization prompt
Use cases
- Planning a zero-downtime schema change
- Sequencing a migration so old and new code coexist
- De-risking a destructive column or table change