Plan a schema migration that runs under live traffic
I need to change a database schema while the app keeps serving traffic. Current shape: {{tables, columns, types, indexes, row counts}}. Target shape: {{what it should become}}. Stack and database: {{e.g. Postgres 15, Rails}}. Deploy model: {{rolling, blue-green, single instance}}.
Produce a plan as numbered phases, each one independently deployable and safe with the previous version of the code still running:
1. Expand - additive schema changes only. Give the exact DDL and say which statements take locks, which are online, and roughly how long each will run at my row counts.
2. Backfill - batched, resumable, with the batch size and the throttle, and how to verify completion.
3. Dual write and dual read, and which one ships first.
4. Contract - what to drop, and the earliest deploy at which it is safe.
5. For every phase: the rollback, and whether rollback is still possible after it.
Then list the checks to run between phases, and the failure that would be unrecoverable. Do not assume a maintenance window. Do not use a tool I have not named.
How to use it
Row counts change the answer completely - guessing them is the main way this plan goes wrong. Lock and duration estimates are educated guesses, not measurements; rehearse the DDL on a production-sized copy before you trust the timings.
Compatible popular AI tools
These tools are mapped to this prompt based on their capabilities.
People who liked this prompt
0 community likes