Skip to content

Database Package (@ce-sdr/db) ​

Located at packages/db/, this package is the single source of truth for the database schema, Prisma client, and generated types.

Stack ​

  • Database: MongoDB Atlas
  • ORM: Prisma (v6+)
  • Schema: packages/db/schema.prisma
  • Generated client: packages/db/generated/client/
  • Generated Zod types: packages/db/src/lib/zod/ (via zod-prisma-types)

Commands ​

bash
pnpm db:generate   # Re-generate Prisma client + Zod types (run after every schema change)
pnpm db:push       # Push schema to MongoDB (no migration files — MongoDB is schemaless)
pnpm db:seed       # Run seed scripts
pnpm db:studio     # Open Prisma Studio web UI

MongoDB with Prisma uses db push rather than migration files. There is no migrate dev / migrate deploy workflow.

Exports ​

Everything is re-exported from packages/db/src/index.ts:

  • Prisma client — import { prisma } from "@ce-sdr/db"
  • Zod schemas — import { CampaignsSchema, ContactsSchema, ... } from "@ce-sdr/db"
  • Enums — import { CampaignStatus, StepType, ... } from "@ce-sdr/db"

Schema Overview ​

See Database Schema for the full ERD and field definitions.