Build

Database

Drizzle schema, migrations and safe data checks.

01Schema and migrations

db/schema.ts is the only schema file. Change it, then generate and apply a migration:

Terminal
npm run db:generate -- --name add-invoices
npm run db:migrate

Never use db:push: it skips the migration log and breaks db:migrate later.

02Inspect data

Terminal
npm run db:query -- "select id, email from users limit 5"
npm run db:query -- --tables
npm run db:query -- --describe users
npm run db:studio

db:query is read-only, so it's safe to hand to an agent. db:studio opens Drizzle Studio in the browser.

03Seed and RLS

npm run db:seed copies the plans and credit packs from config/plans.ts (upserted by slug, safe to re-run) and adds a verified admin (set SEED_EMAIL and SEED_PASSWORD to choose them). Document search uses pgvector, which Supabase and Neon include. On Supabase, run db/enable-rls.sql once.