Adding a database entity
- Add the model to the schema file for its domain (
prisma/schema/NN-name.prisma), not a new single-file schema. - Use UUID v7 if the model matches the operational tables:
@default(uuid(7)). - If the row is tenant-owned, include
tenantIdand@@unique([id, tenantId])so child relations can carry the tenant. Point foreign keys at the composite where existing models do. - Add
deletedAtif the aggregate follows the soft-delete rule, and filterdeletedAt: nullin queries. - Classify the model in
tenancy.extension.tsas direct, indirect, or global. Global is rare. The current global set isIntegrationRegistry,Permission,PlatformRolePermission,Currency,FxRate. - Create the migration. See Adding a migration.
- If a status field has legal edges, add a TypeScript map next to the service. Do not rely on a header comment. The order files show why.
- Extend the architecture test’s expectation if it enumerates models.
Raw SQL you add later must repeat tenantId. The extension will not inject it into $queryRaw.