Files
starter-e2e-mrf84key/db/annotations.ts
2026-07-10 19:42:56 +02:00

22 lines
1.1 KiB
TypeScript

// Column annotations — compiled by `pikku db migrate` into db/annotations.gen.json,
// which drives BOTH the generated types/zod AND runtime value coercion.
//
// Declare a `kind` for every semantic date/bool/json column you add:
// - kind: 'date' → the column types as `Date` end-to-end. Write real `Date`
// objects, read back `Date` objects; the TEXT storage is coerced both ways.
// - kind: 'bool' → types as `boolean` over the INTEGER 0/1 storage.
// - kind: 'json' → parsed/serialized automatically.
// Without a kind, a SQLite date column is just `string` (write ISO strings via
// `new Date().toISOString()`) and a flag is `number` — that default is fine too;
// just follow the generated type, never fight it with `new Date()` writes or casts.
//
// Optional per column: security ('public' | 'private' | 'pii' | 'secret'),
// classification (anonymize strategy), tsType, format, description.
export const classifications = {
// Example — after adding a `todos` table in a migration:
// todos: {
// created_at: { kind: 'date' },
// done: { kind: 'bool' },
// },
}