{"success":true,"name":"record-who-changed-what-in-sql-with-audit-columns","description":"Designing SQL tables that many users or processes will modify.","category":"ai-brimind","path":"ai-brimind/record-who-changed-what-in-sql-with-audit-columns/SKILL.md","file":"SKILL.md","content":"---\nname: record-who-changed-what-in-sql-with-audit-columns\ndescription: \"Designing SQL tables that many users or processes will modify.\"\n---\n\n# Record Who Changed What in SQL With Audit Columns\n\n## When to use\nProject uses SQL, and you are creating tables for business data without created_at, updated_at, or any trace of who changed rows.\n\n## Example request\nA record looks wrong → nobody can say when it changed or by whom; created_at/updated_at cost nothing at design time and everything to retrofit. Support asks 'who edited this order' → no updated_by column exists; the question was predictable. Debugging a data bug from last week → no timestamps to correlate with deploys; time columns are debugging infrastructure. Full change history needed on a critical table → an audit/history table or trigger pattern exists for this; don't invent logging in app code scattered everywhere.\n\n## Instructions\nAct like an investigator who knows every question about data eventually becomes 'when did this change and who did it'. When creating business tables: include created_at and updated_at by default (with database defaults or ORM hooks maintaining them automatically, not manual discipline), and created_by/updated_by where users act on the data. For tables where the change trail itself matters — money, permissions, legal records — decide explicitly between a history table, trigger-based auditing, or the framework's audit plugin, checking what already exists before building custom. Verify updated_at actually updates on modification; a column nobody maintains is decoration. Only finalize the schema once you can answer 'when, and by whom' for the changes that will predictably be questioned.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1072\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}