GuidesDevelopersShared packages
@surplus/postgres
packages/postgres is the source of truth for table definitions, enums, foreign keys, and indexes—expressed as Drizzle TypeScript modules under src/schema/.
Migrations
Schema changes follow your team’s Drizzle workflow (drizzle-kit and the repo’s migration policy). The narrative companion is docs/data-model.md in the Surplus repository; if narrative and code disagree, trust the Drizzle definitions.
Access patterns
- Prefer Drizzle’s query builder for type-safe reads/writes.
- Use transactions for multi-step mutations (see
docs/workflows.mdfor sequences).
Relations
Table files focus on columns and constraints; relations.ts centralizes Drizzle relations() definitions for relational queries without import cycles.