Migrations

Drizzle Kit is configured in drizzle.config.ts:

schema: "./src/lib/db/schema/index.ts",
out: "./src/lib/db/migrations",
dialect: "postgresql",
dbCredentials: { url: process.env.DATABASE_URL! },

Commands

Command Purpose
npm run db:push Apply schema directly to DB — no migration file. Fast for dev.
npm run db:generate Diff schema vs. DB, emit SQL file in src/lib/db/migrations/
npm run db:migrate Apply pending migration files in order
npm run db:studio Open GUI

Dev workflow

  1. Edit a table in src/lib/db/schema/*.ts.
  2. npm run db:push — apply against your local/preview Neon branch.
  3. For production: switch to db:generate → commit SQL → db:migrate in CI.

Migration directory

src/lib/db/migrations/ — generated SQL + Drizzle metadata.

Current state: one consolidated initial migration 0000_*.sql covering all 16 tables. Going forward, schema changes should use db:generate to create incremental migrations committed to the repo, then db:migrate in the deploy pipeline.

Neon branching

Neon supports branching — create a throwaway branch per PR to test destructive migrations without touching prod.