Skip to main content

Database Workflow

Last reviewed: 2026-04-21
Maintained by: Engineering

Migration Flow

Create migration:

pnpm run db:migrate:create your-migration-name

Apply migrations:

pnpm run db:migrate

Rollback latest migration:

pnpm run db:migrate:down

Drift Checks

Check migration/schema snapshot drift:

pnpm run db:schema:check

Sync schema snapshot after intentional migration changes:

pnpm run db:schema:sync

Standard Sequence for Schema Changes

docker compose up -d postgres
pnpm run db:migrate
pnpm run seed:demo
pnpm run db:schema:check

If db:schema:check fails and drift is intentional:

pnpm run db:schema:sync
pnpm run db:schema:check

Rules

  • Never edit already-applied historical migrations.
  • Every schema change must be a new migration.
  • database/migrations is source of truth.
  • database/schema.snapshot.sql must match current migrations.