@toolctrl/db
Database ownership package.
This package owns the server-side Prisma client boundary, the generated Prisma TypeScript client, and the repository database command surface while the root schema and migrations remain in their existing locations.
Current ownership:
- Schema:
prisma/schema - Migrations:
prisma/migrations - Generated client:
packages/db/generated/prisma/client - Prisma 7 TypeScript entrypoints:
packages/db/generated/prisma/client/client.tsandpackages/db/generated/prisma/client/browser.ts - Server client API:
@toolctrl/db/client.server
Use getDbClient() from @toolctrl/db/client.server for server-side Prisma client creation and development singleton reuse.
Transaction helpers are available from @toolctrl/db/transactions.server and the root package export. runDbTransaction(callback, client?) wraps interactive Prisma transactions behind an injectable client, while runDbTransactionBatch(operations, client?) runs batch operations without forcing app imports.
Seed helpers are available from @toolctrl/db/seed.server and the root package export. runDbSeed({ nodeEnv, adminEmail, adminPassword, seedCredentials, seed, diagnostics }) runs exactly one caller-provided seed callback, rejects production runs that still use local default seed emails or the default password, emits start / success / failure diagnostics, and never includes password values in diagnostic events. Use assertSafeSeedCredentials(options) when a caller needs to perform the production credential guard separately.
Package scripts delegate to the current root Prisma config while keeping callers on the @toolctrl/db package:
pnpm --filter @toolctrl/db prisma:generatepnpm --filter @toolctrl/db prisma:migrate:deploypnpm --filter @toolctrl/db seedpnpm --filter @toolctrl/db permissions:syncpnpm --filter @toolctrl/db typecheck
For the non-E2E database CI status gate, see Database CI runbook. The root pnpm run verify:db-migrate-status command checks Prisma migration status through this package boundary and requires a configured DATABASE_URL secret.
Root-facing scripts use the same package boundary instead of invoking Prisma or the seed file directly:
pnpm run db:generatepnpm run db:migrate:deploypnpm run seedpnpm run permissions:syncpnpm run buildpnpm run typecheck
Planned ownership:
- Migrate app, API and worker database imports to package APIs.
- Keep schema and migrations in
prisma/until a separate migration explicitly moves those files.
Decision records:
- ORM Decision Record: preserve Prisma for now; evaluate Prisma 7 vs Drizzle after database package boundaries are stable.