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/migrationsis source of truth.database/schema.snapshot.sqlmust match current migrations.