// Schema for the {{projectName}} backend — a `users` table with the // `deactivation()` mixin. `actors` + `tenants` are the framework core tables. import { databaseHandle, id, table, text, timestamp, type InferRow, } from '@voltro/database' import { deactivation } from '@voltro/plugin-deactivation' 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'), }) export const users = table('users', { id: id(), email: text().unique(), name: text(), }) // deactivation() adds deactivatedAt + deactivatedBy (→ actors) and pulls // audit() transitively (createdAt/updatedAt/createdBy/updatedBy). NOTE: no // defaultWhere — a deactivated user still shows up in queries, unlike // softDelete() which would hide it. .with(deactivation()) export type User = InferRow export const database = databaseHandle({ actors, tenants, users })