Skip to content

Work / Babul / Wiki / Decisions

schema

Decisionverified 2026-10-23

Schema

Choice: 40 tables in packages/db/prisma/schema.prisma, one migration, no data kept. Rules that must hold:

  • Every company row carries clientId; children's foreign keys include clientId and productId; row-level security per company and per chosen product.
  • One Job table is the queue for everything slow (capture, verify, analysis, images, export, email), with retries and runAfter.
  • One Change row per property, in a draft or a commit. One private draft per person per ref. A version is a Version row with its bump.
  • Role passwords are sealed and readable only by the worker. One AiAction row per AI call for the meter.

Rejected: the 50-table schema (Kit, Interaction, StyleSection, Tag, Import, CaptureRun, DrawnElement and others) · invoices in our database (Polar keeps them).