D33 · A migration's author regenerates the database types
Accepted · 2026-10-12 · zuki · Closes OQ21
Decision: Whoever changes a file in supabase/migrations runs pnpm db:types and commits the regenerated packages/db-types in the same pull request, so that the schema and its types land on main in one squashed commit. The types are never edited by hand (D22). CI's database job regenerates them and fails on any difference (D12, TL-M0-18), so a pull request that forgot them can't merge.
When the new types break apps/web's typecheck, the Backend Engineer doesn't change apps/web. The pull request names the pages that fail, and the Frontend Engineer fixes them on the same branch before zuki merges, so main never holds a schema whose app doesn't typecheck. A schema change that only adds (a new table, column, function or enum value) usually breaks nothing.
Why: Only the author of a migration knows when the schema has changed, and CI enforces the result either way once the database job runs. Regenerating later, in a separate change, would leave main with types that don't match its own migrations.
Consequences: The Backend Engineer's step packs that change a migration end with pnpm db:types and include packages/db-types in their pull request. An agent never edits packages/db-types except by running pnpm db:types.