Database & Drizzle

SigmaNext targets PostgreSQL. Schema is defined in TypeScript with Drizzle ORM; SQL migrations live under drizzle/.

Workflow

1. Edit lib/db/schema.ts

2. Generate a migration:

npm run db:generate

3. Apply to the database:

npm run db:migrate

Good practices

  • Run migrations in CI/CD before or as part of deploy — never hand-edit production without a migration file.
  • Use a direct (non-pooled) connection string for Drizzle Kit if your host requires it.
  • Back up production before destructive migrations; test upgrades on staging first.
  • Keep ON CONFLICT / idempotent patterns for webhook-fed tables (e.g. orders) so retries do not corrupt data.
Neon, Supabase, RDSAny Postgres-compatible provider works. For serverless functions, prefer HTTP-capable drivers (e.g. Neon serverless) where latency matters.