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:
npm run db:generate -- --name add-invoices
npm run db:migrateNever use db:push: it skips the migration log and breaks db:migrate later.
02Inspect data
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:studiodb: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.