uw-analyze-database
Analyzing Database Layer
Output: docs/unwind/layers/database/ (folder with index.md + section files)
Principles: See analysis-principles.md - completeness, machine-readable, link to source, no commentary, incremental writes.
The data model is code-first; SQL is its physical contract
For a rebuild in a different stack, the canonical data model is the code-side representation — the ORM models/entities (Drizzle, Prisma, TypeORM, SQLAlchemy, Mongoose, Sequelize, JPA, EF Core). That is where the field names, types, relations, defaults, and business rules live, and it is what the rebuild reproduces.
Raw SQL DDL (CREATE TABLE, migrations) is a contract, not the model. When
the deterministic scan finds a code-side model, it makes that the canonical table
candidate and reconciles matching SQL DDL onto it (demoting the migration's
CREATE TABLE to a db-ddl contract linked via dataModelLinks). So: