Plan a Zero-Downtime Migration Between Two Database Schemas

Read the story behind this prompt
Regression testing checklist template (with AI prompts)
Read the articleTap any variable to replace it with your own value:
AI prompt
Plan a zero-downtime migration from an old database schema to a new one. Old schema: [describe or paste the relevant tables/columns]. New schema: [describe the target structure and why it's changing, e.g. 'splitting a single users table into users and user_profiles']. Scale: [approximate row counts and whether this table is read-heavy, write-heavy, or both]. Produce a step-by-step migration plan using the expand-contract pattern: (1) the 'expand' phase - what gets added alongside the old structure without breaking anything currently reading it; (2) the dual-write or backfill step that populates the new structure from existing data, including how to handle rows that don't cleanly map; (3) the cutover point - what changes in the application code to start reading from the new structure, and how to verify parity between old and new before fully switching; (4) the 'contract' phase - what old columns/tables get safely dropped, and how long to wait before doing that. Flag the single riskiest step in this specific migration and what could go wrong there.
Related prompts
- Database schema designer with migrations and indexing
Design the target tables, indexes and rollout steps before you migrate.
- Get a senior-engineer critique of your database schema before you commit to it
Check the new structure for costly flaws before moving live data.
- Write a Regression Test Checklist for a Risky Refactor
Write the checks that catch silent breakage during schema rollout.
- Audit Your Database Indexes Against How the App Actually Queries It
Review indexes for both old and new queries during the transition.