// Schema for the {{projectName}} SaaS backend. // // One tenant-scoped `projects` table — the SaaS plugins (billing entitlements, // notifications, analytics, presence) layer on top via `app.config.ts`; they // contribute their OWN tables (`_voltro_billing_*`, `notification_*`, // `_voltro_events`, `_voltro_presence`) automatically, so you don't declare them. // // `actors` + `tenants` are the framework's core tables (the audit / tenant // mixins reference them). import { databaseHandle, id, table, text, timestamp, type InferRow, } from '@voltro/database' import { tenant } from '@voltro/plugin-multitenancy' // ---------- Core tables ---------- export const actors = table('actors', { id: id(), kind: text().oneOf(['user', 'serviceAccount', 'apiKey', 'system']), displayName: text().nullable(), createdAt: timestamp().default('now'), }) export const tenants = table('tenants', { id: id(), name: text(), createdAt: timestamp().default('now'), }) // ---------- Application table ---------- export const projects = table('projects', { id: id({ prefix: 'proj' }), name: text(), }) // tenant() pulls audit() transitively → tenantId + createdAt / updatedAt / // createdBy / updatedBy (auto-stamped). Creating a project is gated by the // billing `projects` entitlement (see mutations/projects.create). .with(tenant()) export type Project = InferRow export const database = databaseHandle({ actors, tenants, projects })