Prerequisites
Before building Prisma Engines, ensure you have the following installed:Rust Toolchain
Rust Toolchain
Install the latest stable Rust version:Or use your package manager:
OpenSSL (Linux only)
OpenSSL (Linux only)
Required for database connections on Linux:
direnv
direnv
Recommended for managing environment variables:After installation, hook direnv into your shell by adding to
~/.bashrc or ~/.zshrc:Docker (for databases)
Docker (for databases)
Required for running test databases:
Node.js & pnpm (for driver adapters)
Node.js & pnpm (for driver adapters)
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:.envrc automatically.
Building the Engines
Prisma Engines uses Cargo’s workspace feature to manage multiple crates.Build All Engines (Debug)
target/debug/:
| Engine | Binary Path |
|---|---|
| Schema Engine | target/debug/schema-engine |
| Prisma Format | target/debug/prisma-fmt |
Build All Engines (Release)
For optimized production builds:target/release/:
| Engine | Binary Path |
|---|---|
| Schema Engine | target/release/schema-engine |
| Prisma Format | target/release/prisma-fmt |
Build Query Compiler WebAssembly
The query compiler compiles to WebAssembly for use in Prisma Client:query-compiler/query-compiler-wasm/pkg/.
Build Driver Adapters Kit
To build the driver adapters with query compiler integration: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: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
- Starts a PostgreSQL container via docker-compose
- Builds query compiler WebAssembly
- Builds driver adapters
- Writes
.test_configfile
Set Up Other Databases
Available database helpers:Run Query Engine Tests
After setting up a database:Run Schema Engine Tests
Schema engine tests require database environment variables:Development Workflow
Here’s a typical development workflow:Make your changes
Edit source files in your preferred editor. Consider using rust-analyzer for IDE features.
Debugging
Useful debugging techniques:Enable Logging
Control log levels with theRUST_LOG environment variable:
Use Debug Macros
Add debug output in your code:Language Server
Use rust-analyzer for:- Go to definition
- Type information
- Inline errors
- Code navigation
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:Make changes
Edit query compiler code in
prisma-engines and driver adapter code in prisma/packages/adapter-*.Configure CI integration
Add to your PR description in GitHub Actions will use that branch from
prisma-engines:prisma/prisma for CI tests.Integration Releases
Test your changes in the full Prisma ecosystem:Automatic Integration Releases
Branches starting withintegration/ automatically trigger:
- Full test suite in
prisma-engines - Build and upload engines to S3 & R2
- Trigger
@prisma/engines-wrapperrelease - Create integration PR in
prisma/prisma - Publish all Prisma packages to npm with
integrationtag - 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
Common Issues
Missing TEST_DATABASE_URL error
Missing TEST_DATABASE_URL error
Integration tests require database URLs:
Snapshot test failures
Snapshot test failures
Regenerate snapshots when intentionally changing output:Review changes carefully before committing.
Cargo build locks
Cargo build locks
rust-analyzer can lock the build directory. Configure a separate target directory (see Debugging section).
OpenSSL errors on Linux
OpenSSL errors on Linux
Install OpenSSL development packages:
WebAssembly build fails
WebAssembly build fails
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
- Prisma Documentation - User-facing documentation
- Rust Book - Learn Rust programming
- Cargo Guide - Cargo package manager
- GitHub Actions Workflows - CI/CD configuration