/** * Client-side schema declaration. * * This is the contract between the local sync engine and the Postgres tables * defined in `components/server/migrations/`. The engine uses it to: * - shape the local SQLite tables that mirror Postgres, * - decide which incoming rows to accept, * - type the results returned from `useQuery`. * * Rules of thumb: * - Every Postgres table the UI reads from MUST appear here. * - Column names must match the Postgres column names exactly. * - Primary keys (`id`) are implicit — don't redeclare them. * - SQLite has fewer types than Postgres. Use `column.text` for strings, * `column.integer` for numbers and booleans (0/1), `column.real` for * floats. Timestamps are stored as `integer` (epoch millis) for cheap * comparisons. * * To add a new table: * 1. Add the migration in `components/server/migrations/`. * 2. Add a `new Table({...})` for it here. * 3. Add it to the `new Schema({...})` call below. * 4. Restart the server — `deploy.ts` will pick it up and tell the sync * service to start replicating it. */ import { column, Schema, Table } from '@powersync/web'; const items = new Table({ text: column.text, done: column.integer, created_at: column.integer, }); export const appSchema = new Schema({ items });