// Schema for the {{projectName}} webhooks backend. // // `webhookTables()` contributes the framework's two bookkeeping tables — // `_voltro_webhook_targets` (who subscribed to an outgoing event) and // `_voltro_webhook_deliveries` (each delivery attempt). They're auto-migrated // alongside your own tables; you register them by exporting them here. import { databaseHandle, id, integer, table, text, type InferRow, } from '@voltro/database' import { tenant } from '@voltro/plugin-multitenancy' import { webhookTables } from '@voltro/plugin-webhooks/mixin' // ---------- Core tables ---------- export const actors = table('actors', { id: id(), kind: text().oneOf(['user', 'serviceAccount', 'apiKey', 'system']), displayName: text().nullable(), }) export const tenants = table('tenants', { id: id(), name: text() }) // ---------- Application table ---------- export const orders = table('orders', { id: id({ prefix: 'order' }), sku: text(), totalCents: integer(), status: text().oneOf(['pending', 'fulfilled']).default('pending'), }) .with(tenant()) export type Order = InferRow // ---------- Webhook bookkeeping (framework-managed) ---------- const [webhookTargets, webhookDeliveries] = webhookTables() export { webhookTargets, webhookDeliveries } export const database = databaseHandle({ actors, tenants, orders, webhookTargets, webhookDeliveries, })