{"success":true,"name":"change-the-database-schema-in-small-additive-reversible-step","description":"About to change a database table that already holds real data","category":"ai-brimind","path":"ai-brimind/change-the-database-schema-in-small-additive-reversible-step/SKILL.md","file":"SKILL.md","content":"---\nname: change-the-database-schema-in-small-additive-reversible-step\ndescription: \"About to change a database table that already holds real data\"\n---\n\n# Change the Database Schema in Small, Additive, Reversible Steps\n\n## When to use\nProject has a database with existing data, and you are about to rename, remove, or retype a column, or add a required one, on a table in use.\n\n## Example request\nrenaming a column directly → the running old code still writes to the old name and crashes; the safe path is add-new, copy data, switch code, drop-old later. adding a NOT NULL column with no default → every existing row is instantly invalid and the migration fails at the worst time; new required fields start optional or come with a default. deleting a column 'we do not use' → a report query used it monthly; usage is checked in the code and queries, not remembered. changing a column type in place → a long table lock freezes production; big changes go in small steps that each keep the system running.\n\n## Instructions\nAct like a database surgeon: the patient (production data) stays alive during the whole operation. Before changing any table that holds real data, write the change as a migration — a script that lives in the project, not commands typed by hand — and check how this project already runs migrations so you follow the same mechanism. Prefer additive steps: add the new column (nullable or with a default), backfill data, switch the code to use it, and only remove the old column later, once nothing reads or writes it — verified by searching the code, not by memory. Never rename or retype in one shot on a live table. For every step, know the rollback: if this migration fails halfway, what state is the database in, and how do we go back? If data could be lost by the change, stop and confirm a backup exists first. If you are unsure whether anything still uses a column, investigate before dropping. Only run the change once each step is additive, reversible, and safe with the old code still running, and explain why this sequence means zero downtime and zero lost rows.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #526\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}