// Schema for the {{projectName}} search backend. // // `articles` is the searchable domain. The search plugin mirrors every // write to it into a search index (see app.config.ts + lib/search.ts); the // table itself is an ordinary `tenant()`-scoped reactive table. import { databaseHandle, id, table, text, timestamp, type InferRow, } from '@voltro/database' import { tenant } from '@voltro/plugin-multitenancy' // ---------- Core tables (required by the audit / tenant mixins) ---------- 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 articles = table('articles', { id: id({ prefix: 'art' }), title: text(), body: text(), tag: text(), // a coarse category — also a search filter }) // tenant() adds tenantId + audit columns (auto-stamped). The search // index's `tenantField: 'tenantId'` scopes every query to the caller. .with(tenant()) export type Article = InferRow export const database = databaseHandle({ actors, tenants, articles })