Write a Safe Bulk Update
Added 2026-11-04
Small batches, verify, allow interruption; never one statement over the whole table.
We need a bulk update (table and condition below). Write the process: 1) a dry run that estimates affected rows and key distributions; 2) batch size and ordering; 3) what to verify after each batch; 4) how to prevent double application — idempotent conditions; 5) how to interrupt and roll back; 6) where collateral damage is most likely. Do not give a single full-table UPDATE.
Site original
Chinese original
How to use
批量操作的安全来自「可以停下来」。
Try tweaking it
- Have it restate requirements and constraints before writing code.
- Ask for the smallest change plus a rollback path, not a full-file rewrite.
What you should get
- A minimal, runnable change with copy-ready code
- Impact list: which files and call sites must follow
Common mistakes
- Asking it to touch ten files at once, then losing track of what broke what.
- Pasting only the error, with no code or version, and getting an unfixable answer.
How to check the output
- The change runs, can be rolled back, and touches nothing unrelated.
- Edge cases (empty, oversized, concurrent) are covered or explained.
Where it works
- Good for: having it restate requirements and constraints, then propose the smallest runnable change.
- Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.