Megamono

DOCUMENTATION

On this page
  1. Preview a new database project
  2. Add models and build
  3. Connect the consuming application
  4. Verify the deployed artifact

Build and consume a Prisma client

Create an opt-in Prisma client library and connect generation, compilation, and application builds.

Use a buildable database project when an application needs a compiled, exported Prisma client. Without --buildable, the database generator retains its schema-oriented validate/generate workflow.

Preview a new database project

bash
megamono add database primary --adapter=prisma --buildable --client-output=src/db/client --dry-run

Review the plan, then repeat with --yes instead of --dry-run. --client-output is relative to the database project, not the workspace root. If omitted, the buildable profile uses src/generated.

This opt-in profile is for a new Prisma 7 ESM client library. It targets Prisma/client 7.10.0 and the engine-free generator. Conflicting existing dependency selections require review; this command is not an automatic conversion of an existing schema, custom generator, or engine-based client.

Add models and build

Add your application's models before generation. Inspect the generated schema and Prisma configuration rather than replacing them wholesale. The configuration loads the workspace .env relative to the config file so invocation from Nx or another directory has the same environment-loading behavior.

Find the generated project name, then build it:

bash
npm exec -- nx show projects
npm exec -- nx show project <database-project>
npm exec -- nx run <database-project>:build

Replace <database-project> with the name shown by Nx. The build target depends on generation, compiles the client, and exposes ESM JavaScript and declarations through the package export. The package stays private; “buildable” does not mean registry-published.

Connect the consuming application

Use the package name from the generated package.json, not a deep import into the generated source directory. For example, if its name is @acme/prisma-primary:

ts
import { PrismaClient } from '@acme/prisma-primary';

Declare the database library as a dependency of its consuming workspace package. Ensure the application build waits for the database library's build, through a verified Nx dependency graph and ^build dependency or an explicit project-target dependency. Inspect resolved targets; an import alone does not prove build ordering.

The application must install and configure its PostgreSQL driver adapter and own the Prisma client lifecycle, connection credentials, shutdown, and migrations. Client generation and TypeScript compilation do not connect to a database or apply migrations.

Verify the deployed artifact

Include the database library's dist files and declared runtime dependencies in the deployment. Smoke-test its package import and application startup in the actual image or clean runtime, not only in the monorepo checkout. Qualify the database connection separately against disposable infrastructure.

The engine-free profile does not package native engines for older clients. Existing engine-based clients still need their own generation and native-engine deployment strategy. When adopting or relocating an existing schema, review ownership metadata, imports, build dependencies, environment loading, and migration commands together.

See database options, runtime verification, and container verification.

Megamono

One repository system for the applications, tools, and people building together inside it.

BUILD

Get startedGuidesDocumentationCLI referenceCapabilitiesInference

SOURCE

GitHub ↗

MIT licensed

© 2026 Megamono

By

Commune Software