Safe database schema migration plan prompt

Plan a safe database schema migration with zero-downtime steps, backfill strategy, rollback plan and checks before and after each deploy.

Published
Works with
ChatGPT, Claude and Gemini
Level
Advanced
By
GoodAIPromt editorial team

Renaming a column or splitting a table looks simple until it locks a big table in production or breaks the old version of the app during deploy. A safe database schema migration plan breaks the change into small, reversible steps. This prompt asks the AI to design an expand-and-contract plan for your database and stack, with backfills, rollbacks and checks at each step.

The prompt

Act as a senior backend engineer who has run many production database migrations.

Database and version: 
ORM or migration tool: 
Current schema (relevant tables): 
Change I want: 
Table size and traffic: 
Deploy process: 

1. Explain the risks of doing this change in one step (locks, downtime, app compatibility).
2. Design an expand-and-contract plan as numbered deploys, each with: migration SQL or code, app changes, and why it's safe while old and new versions run together.
3. Write a batched backfill approach with batch size, throttling and how to resume.
4. Give a rollback plan for each step.
5. List checks before and after each step (row counts, null checks, query plans, error rates).
6. Point out anything that depends on my database version and should be verified in the docs.

Show code in my migration tool's format where possible.

0 of 6 blanks filled

How to use it

  1. Paste the real DDL and table sizes; the safe approach depends on them.
  2. Test the full plan on a staging copy with production-like data volume.
  3. Run one step per deploy and check the metrics before the next.

Tips

  • Ask for lock timeout settings to add to each migration for safety.
  • Keep the plan in your pull request so reviewers can follow the sequence.

Frequently asked questions

What does this prompt do?

Plan a safe database schema migration with zero-downtime steps, backfill strategy, rollback plan and checks before and after each deploy.

Which AI tools does it work with?

It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.

What do I need to fill in?

6 blanks: e.g. postgresql 16, mysql 8; e.g. rails, django, prisma, flyway; paste ddl; e.g. rename column, split table, change type, add not null column; rows, writes per second, peak hours; e.g. rolling deploys, old and new app versions run together. Click each blue blank on the page, type your details and press Copy prompt.

Is this prompt free to use?

Yes. You can copy and use it for personal and commercial work.

database migrationschema changezero downtimebackend development

More prompts for ChatGPT, Claude, Gemini.