Overview
ChatJS uses PostgreSQL with Drizzle ORM for type-safe, schema-first database access. The schema is defined inapps/chat/lib/db/schema.ts — edit it to change the database structure.
Database Management
Run these commands from theapps/chat directory:
db:push— fastest for local iteration; skips migration files. Not safe for production.db:generate+db:migrate— the production workflow; creates a versioned SQL file and applies it.db:studio— inspect, query, and edit data via a browser UI.
Schema Changes
All schema changes start inapps/chat/lib/db/schema.ts. After editing:
- Run
bun db:generateto produce a migration file indrizzle/. - Review the generated SQL to confirm the diff is correct.
- Run
bun db:migrateto apply it.