{"success":true,"name":"make-every-migration-reversible-or-explicitly-one-way","description":"Writing a script that changes database schema or transforms stored data.","category":"ai-brimind","path":"ai-brimind/make-every-migration-reversible-or-explicitly-one-way/SKILL.md","file":"SKILL.md","content":"---\nname: make-every-migration-reversible-or-explicitly-one-way\ndescription: \"Writing a script that changes database schema or transforms stored data.\"\n---\n\n# Make Every Migration Reversible or Explicitly One-Way\n\n## When to use\nYou are about to run a migration (add/drop/rename columns, reshape documents, backfill values) on data that matters.\n\n## Example request\nColumn renamed in one shot → old code still deployed writes to the old name; data splits across two fields — no transition period. Data reshaped by a script with a bug → half the records converted wrong, original values gone — destructive transform without backup. DROP COLUMN in the same migration that adds its replacement → rollback impossible; the old data is deleted — one-way door taken casually.\n\n## Instructions\nAct like a migration author who plans the retreat before the attack. For every schema or data migration: (1) write the DOWN path — the exact steps to restore the previous state — or explicitly declare 'this is irreversible' and require a data backup taken immediately before running; (2) prefer expand-then-contract: ADD the new column/shape first, backfill it, switch code to use it, and only DROP the old one in a later migration after the new path is proven — never rename-in-place while old code may still run; (3) make the script idempotent where possible (safe to run twice: check-before-insert, IF NOT EXISTS) because reruns happen; (4) test on a copy of real data first and log counts: rows examined, rows changed, rows skipped — a migration that reports nothing is unverifiable. Only run on real data once the rollback story is written, the counts from the test run match expectations, and the destructive step (if any) is scheduled last and separately.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1086\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}