Data & SQL21 categories
Write a safe migration for this change
Changing a schema that live code is already reading and writing.
I need to make the schema change described below against a live database. Produce: 1. The sequence of deploys required for zero downtime, stating for each step what the application code must tolerate. Assume old and new code run simultaneously during rollout. 2. The forward migration SQL, and the rollback for each step, or a plain statement that a step is irreversible. 3. Locking behaviour: which statements take a lock, of what kind, and how long at my row count. Flag anything that blocks writes. 4. Backfill strategy for existing rows: batched, resumable, and with the batch size stated. 5. What to verify between steps before proceeding. If the change cannot be done safely as described, say so and propose the closest safe alternative. Change I need: Current schema: Approximate row count: Database and version:
Making it yours
- Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
- Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
- If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.
Schema and data quality. Designing tables, migrating them without breaking live code, and cleaning what you have been handed.
Related prompts
Review this schema designBefore you create the tables everyone will depend on for years.Write data quality checks for this tableBefore you trust a table you've just been handed.Plan the cleanup of a messy columnFree-text data that half-works and needs to become reliable.Choose the shape for this report's dataDeciding between wide, long, or pre-aggregated before you build anything.Explain this query to me line by lineYou inherited a 200-line query and need to understand it before changing it.Make this slow query fasterA query that used to be fine now takes minutes.
Keep this one
Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.
Add to your browser โ free