The Codegen Tool That Wrote a Migration We Never Reviewed
We wanted Zod schemas from Drizzle definitions. The assistant named drizzle-zod-codegen. The package generated schemas, and it also appended a migration file to our drizzle folder that we pushed without reading.
What the migration did
Created a table with a trigger that copied rows out of users into a shadow schema on the next db:push. Our staging push ran Saturday. Our review process for generated SQL was a glance and an approval.
How we caught it
Our database auditor flagged an unfamiliar schema during a routine snapshot comparison. Three thousand user rows had been mirrored. The shadow schema had no read grants, so nothing had been exported yet.
Repair
Dropped the schema and trigger, rolled back the migration, rotated the database credentials, and moved to generating schemas with drizzle-zod. Nobody enjoyed explaining to a client why user emails sat in an unknown schema for two days.
Habit change
Generated migrations are reviewed line by line now. If a tool writes SQL we intend to run against production, it is code, and it gets the same scrutiny.