Skip to main content

Prerequisites

Before building Prisma Engines, ensure you have the following installed:
Install the latest stable Rust version:
Or use your package manager:
Required for database connections on Linux:
Recommended for managing environment variables:
After installation, hook direnv into your shell by adding to ~/.bashrc or ~/.zshrc:
Required for running test databases:
Required for building driver adapters and running query compiler tests:
Nix users: If you use Nix, simply run direnv allow in the repository root. The included shell.nix provides all dependencies.

Clone the Repository

Clone the prisma-engines repository:
If using direnv:
This loads environment variables from .envrc automatically.

Building the Engines

Prisma Engines uses Cargo’s workspace feature to manage multiple crates.

Build All Engines (Debug)

This builds all engines in debug mode. Binaries are located in target/debug/:

Build All Engines (Release)

For optimized production builds:
Release binaries are in target/release/:
Release builds are significantly slower to compile but produce much faster binaries. Use debug builds during development.

Build Query Compiler WebAssembly

The query compiler compiles to WebAssembly for use in Prisma Client:
This produces WebAssembly bundles in query-compiler/query-compiler-wasm/pkg/.

Build Driver Adapters Kit

To build the driver adapters with query compiler integration:
This builds both the query compiler WebAssembly and the TypeScript driver adapter code.

Running Tests

Prisma Engines has comprehensive test suites. Tests are organized into unit tests and integration tests.

Unit Tests

Run unit tests for the entire workspace:
Or run tests for a specific crate:
Use UPDATE_EXPECT=1 before the command to regenerate snapshot expectations when diagnostics or output changes:

Integration Tests

Integration tests require running databases. Use the provided Makefile helpers:

Set Up PostgreSQL

This:
  1. Starts a PostgreSQL container via docker-compose
  2. Builds query compiler WebAssembly
  3. Builds driver adapters
  4. Writes .test_config file

Set Up Other Databases

Available database helpers:
The *-qc variants build driver adapters automatically. Use non-*-qc variants (like make dev-postgres15) if you only need a database without driver adapters.

Run Query Engine Tests

After setting up a database:
Or use the Makefile:
To test with a specific driver adapter:

Run Schema Engine Tests

Schema engine tests require database environment variables:

Development Workflow

Here’s a typical development workflow:
1

Set up your environment

2

Start a database

3

Make your changes

Edit source files in your preferred editor. Consider using rust-analyzer for IDE features.
4

Build your changes

5

Run relevant tests

6

Update snapshots if needed

7

Lint and format

Debugging

Useful debugging techniques:

Enable Logging

Control log levels with the RUST_LOG environment variable:
See env_logger documentation for more options.

Use Debug Macros

Add debug output in your code:

Language Server

Use rust-analyzer for:
  • Go to definition
  • Type information
  • Inline errors
  • Code navigation
Install in VS Code via the “rust-analyzer” extension.

Avoid Build Lock Contention

If rust-analyzer locks your builds, configure it to use a separate target directory. In VS Code settings (settings.json):

Testing Driver Adapters

When working on features spanning both query compiler and driver adapters:
1

Clone sibling repository

Clone prisma/prisma next to prisma-engines:
2

Create feature branches

Create branches in both repositories:
3

Make changes

Edit query compiler code in prisma-engines and driver adapter code in prisma/packages/adapter-*.
4

Test locally

This automatically uses driver adapters from your local ../prisma clone.
5

Configure CI integration

Add to your PR description in prisma-engines:
GitHub Actions will use that branch from prisma/prisma for CI tests.
6

Merge order

  1. Merge prisma/prisma PR first
  2. Then merge prisma-engines PR
The /prisma-branch tag is required for CI to test your cross-repository changes. Without it, CI uses the main branch of prisma/prisma, which won’t include your adapter changes.

Integration Releases

Test your changes in the full Prisma ecosystem:

Automatic Integration Releases

Branches starting with integration/ automatically trigger:
  1. Full test suite in prisma-engines
  2. Build and upload engines to S3 & R2
  3. Trigger @prisma/engines-wrapper release
  4. Create integration PR in prisma/prisma
  5. Publish all Prisma packages to npm with integration tag
  6. Run ecosystem tests

Manual Integration Releases

Add [integration] to any commit message:
Integration releases take ~1h20m to complete end-to-end but are fully automated. Monitor both prisma/prisma-engines and prisma/prisma workflows.

Binary Locations

After building, binaries are located at:

Debug Builds

Release Builds

WebAssembly Artifacts

Using Local Engines with Prisma

To use your locally built engines with Prisma Client:

Set Environment Variables

Then run Prisma CLI commands normally:
Add these exports to your shell profile or use direnv in your Prisma project to automatically load local engine binaries during development.

Common Issues

Integration tests require database URLs:
Regenerate snapshots when intentionally changing output:
Review changes carefully before committing.
rust-analyzer can lock the build directory. Configure a separate target directory (see Debugging section).
Install OpenSSL development packages:
Install wasm-pack:

Next Steps

Architecture Deep Dive

Learn about the internal architecture and how components interact

Development Guide

Build, test, and contribute to the engines

API Documentation

Browse the complete API documentation

Contributing

Learn how to contribute to Prisma Engines

Additional Resources