{"success":true,"name":"rehearse-the-change-on-a-copy-before-running-it-on-the-real-","description":"Holding a DB-changing script that has never been executed anywhere yet","category":"ai-brimind","path":"ai-brimind/rehearse-the-change-on-a-copy-before-running-it-on-the-real-/SKILL.md","file":"SKILL.md","content":"---\nname: rehearse-the-change-on-a-copy-before-running-it-on-the-real-\ndescription: \"Holding a DB-changing script that has never been executed anywhere yet\"\n---\n\n# Rehearse the Change on a Copy Before Running It on the Real Database\n\n## When to use\nYou have a concrete script or command that will modify database data or structure, and its very first execution ever would be against the real database — it has never been tried on a copy.\n\n## Example request\nA backfill script is run first on a restored copy → it turns out to skip rows with null fields; the bug is found where it costs nothing. An update matches 12,000 rows on the copy when about 200 were expected → the filter was wrong; the copy just absorbed the mistake meant for production. The script works on the copy and the restore worked to create it → two things were proven at once: the change is safe AND the backup is actually restorable. The rehearsal feels like wasted time → it is the same script run twice; ten minutes of copy-run versus hours of data recovery.\n\n## Instructions\nAct as a pilot who flies the simulator before the plane: the first run of any database change is NEVER on the real thing. Concretely: (1) Build a scratch copy of the real data — restore your fresh backup into a scratch database (pg_restore into a new db, mongorestore into a new database name, or your host's clone feature). This doubles as proof the backup restores; a backup that cannot create the copy just failed its test at the best possible moment. (2) Run the exact change script on the copy — the same file, unmodified, so what you test is what you will run. (3) Verify the result like a tester, not an optimist: count affected rows and compare with what you predicted BEFORE running; open a few changed records and a few that should be untouched; if the app can point at the scratch db, click through the screens that read this data. A surprising count — higher or lower — means the script is wrong, even if nothing 'errored'. (4) If anything surprises you, fix the script and rehearse again on a fresh copy; never carry a 'small surprise' to production hoping it won't matter there. (5) Only after the copy-run matches your prediction exactly do you run the same script on the real database — right after the fresh backup from your backup discipline, with its path and restore command already written down. Only call the change safe once you can say: 'it ran on a real-data copy, it touched exactly the N rows I predicted, and nothing else changed' — 'it looks correct' without a rehearsal is a guess wearing a suit.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #608\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}