The Problem
Traceo’s diagrams page returned 500 errors on every request. The console showed five repeatedBackend returned error response entries. The feature looked fully implemented — React components, API routes, hooks, client service layer — all present and type-checking clean.
The Root Cause
The Drizzle ORM schema defineddiagram and diagram_requirement_link tables with proper TypeScript types, but no SQL migration had ever been created to materialise them in PostgreSQL. Drizzle compiled queries against the schema definition; PostgreSQL responded with “relation does not exist”.
This is a particularly insidious class of bug because TypeScript compilation succeeds — Drizzle validates against schema types, not against the live database. The error only surfaces at runtime.
The Fix
A single migration file (011_diagrams.sql) creating both tables, two enums, indexes, triggers, and RLS policies. The migration pattern follows the existing 008_reconcile_schema.sql structure with idempotent enum creation via DO $$ ... END $$ blocks.
The Takeaway
Every DrizzlepgTable() definition must have a corresponding SQL migration. When debugging 500s on a feature that “looks fully built”, check the migration directory before reading application code. The gap between ORM schema and database DDL is invisible to the type checker.