// Schema for the {{projectName}} public-REST backend. // // `products` is a plain catalog table the REST routes read + write. It // intentionally carries NO mixins — a public REST surface is usually a // separate, explicitly-scoped API (the routes own their auth + filtering), // so we keep the row shape flat and write `id` / `createdAt` by hand in the // handler. (For the tenant()-scoped, reactive-over-WebSocket shape, see the // `api-backend` template.) // // `actors` + `tenants` are the framework's core tables — declared for // convention parity even though no mixin references them here. import { databaseHandle, id, integer, table, text, timestamp, type InferRow, } from '@voltro/database' // ---------- 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 products = table('products', { id: id({ prefix: 'prod' }), name: text(), priceCents: integer(), createdAt: timestamp().default('now'), }) export type Product = InferRow export const database = databaseHandle({ actors, tenants, products })