Welcome! You've arrived at our Contributing page and are now one step away from joining our quest to make databases easy. We're thankful for all your contributions, whether it's helping us find issues in our code, highlighting features we're missing, or contributing to the codebase. If you've found your way here, you'll soon be ready to join in the fun of building features and fixing bugs directly with us - and we're thrilled to have you on board!
To get you started on a good foot, we've created an easy overview of the most important things to get you started contributing code to Prisma below as well as a Code of Conduct for contributing to the development of Prisma.
We also encourage you to join our sprawling community online, where you can discuss ideas, ask questions and get inspiration for what to build next.
Welcome to the monorepo for our TypeScript code for the Prisma ORM. (for the Engines' code written in Rust it's there)
-
Install Node.js
>=18.18
minimum, latest LTS is recommended- Recommended: use
nvm
for managing Node.js versions
- Recommended: use
-
Install
pnpm
(for installing npm dependencies, using pnpm workspaces) -
Install
docker
(for managing databases for our tests) -
Install
ts-node
(for running Node.js scripts written in TypeScript)
Copy paste these commands to install the global dependencies:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
nvm install 18
npm install --global pnpm@9 ts-node
To set up and build all the packages, follow these steps:
git clone https://github.com/prisma/prisma.git
cd prisma
pnpm i
pnpm -r run dev
💡 For Windows users: use the latest version of Git Bash.
In the root directory:
pnpm -r run build
(-r for recursive) will build all the packages.pnpm -r run dev
(-r for recursive) will build all the packages, without runningtsc
.pnpm run watch
will continuously build any packages that have been modified, without runningtsc
(Fastest).
In a package directory, like packages/client
:
pnpm run build
will build the package.pnpm run dev
will build the package without runningtsc
(Fastest).
💡 Our builder is built on top of
esbuild
Create a reproduction folder for developing, trying a new feature, or a fix.
Set up a local project that will be linked to the local packages.
cd sandbox
# Copy a template from the reproduction folder
cp -r basic-sqlite my-repro && cd my-repro
# Install dependencies
pnpm install
# Ensure that the db and the schema are synced
pnpm dbpush
# Do some code changes, always re-generate the client, then try it out
pnpm generate && pnpm start
To run the index.ts
under debugger, do the following steps:
- Run
pnpm debug
from a reproduction folder - In Google Chrome or any Chromium-based browser open
chrome://inspect
page. - Press "Open dedicated dev tools for Node.js" button
- To resume the script go to the "Sources" tab and press "Resume script execution" button (F8).
To add breakpoints use either DevTools UI or add debugger
statements to the source code.
💡 This works best when compiling with
pnpm run watch
in the background.
💡 In any successful setup
pnpm prisma -v
should return version0.0.0
.
Alternatives
cd sandbox
mkdir my-repro
cd my-repro
pnpm init
pnpm add ../../packages/client
pnpm add -D ../../packages/cli
pnpm add -D typescript ts-node
pnpm add -D @types/node
touch index.ts
pnpm tsc --init
pnpm prisma init
# > Manually populate the schema.prisma
# > Manually add 👇 to the generator block
# output = "../node_modules/.prisma/client"
# > Manually populate the index.ts
pnpm prisma db push --skip-generate
pnpm prisma generate && pnpm ts-node index.ts # Try it out
cd packages/client
ts-node fixtures/generate.ts ./fixtures/blog/
cd fixtures/blog
npx prisma db push --skip-generate
ts-node main.ts # Try it out
For an overview, adding, running tests & guidelines see TESTING.md.
We have two kinds of integration tests:
The integration tests consisting of mini projects are located in src/client/src/__tests__/integration
Run the tests:
cd packages/client
pnpm run test integration
If you want to create a new one, we recommend to copy over the minimal test and adjust it to your needs.
It will give you an in-memory Prisma Client instance to use in the test. It utilizes the getTestClient
) helper method.
Sometimes you need an actual generated Client, that has been generated to the filesystem. In that case use generateTestClient
. An example that uses this helper is the blog example
The integration tests consisting of mini project are located in packages/integration-tests/src/__tests__/integration
Run the tests:
cd packages/integration-tests
pnpm run test
The entrypoint for the Migrate CLI is the bin.ts
file.
cd packages/migrate/fixtures/blog
- it's a minimal project that can be used to try things out- Then modify some code
../../src/bin.ts migrate dev
for runningprisma migrate dev
command. (It will usetsx
)
💡 You can also test your changes in a reproduction project via the CLI.
For an overview, adding, running tests & guidelines see TESTING.md.
Tests fixtures are located in ./packages/migrate/src/__tests__/fixtures
- ARCHITECTURE.md
- TESTING.md
- Prisma Docs
- TablePlus is a great GUI for databases, useful for managing sqlite database fixtures for example.
For the list of commands and parameters, you can check out the documentation.
We also maintain a completion spec. It is consumed by the following tools: Warp terminal (macOS only), Fig terminal (macOS only), inshellisense (all OS)
The CLI entrypoint is the bin.ts
file.
This is a list of the top level commands:
- (no command)
db
-> it's a namespacedebug
format
generate
init
introspect
(deprecated and renamed todb pull
)migrate
-> it's a namespacestudio
telemetry
(internal only)validate
version
Some top level commands are namespaces, they do not execute an action without a subcommand (e.g. db
, migrate
).
Each command, namespaces included, and subcommand provides help output via -h
/--help
flags.
Note that the Prisma CLI bundles all its dependencies. If you happen to make changes to dependencies in the monorepo (e.g. @prisma/internals
), you must run at the root level, pnpm -r run dev
or pnpm run watch
to make the changes available to the CLI.
Create a reproduction folder for developing, trying a new feature, or a fix.
When opening a PR these are the expectations before it can be merged:
- There is a description explaining the changes, optimally linking the tracking issue that will be closed when merged.
- If you are a Prismanaut, you can add
/integration
in the description to get a version released to npm to theintegration
tag, see TESTING.md for more details.
- If you are a Prismanaut, you can add
- Tests are written and cover the changes.
Lint
&CLI commands
&All pkgs (win+mac)
GitHub Actions workflows should be successful.- The reported bundle size of
packages/cli/build/index.js
in thesize-limit report 📦
comment in the PR needs to stay below ~6MB. (The comment will be posted by the bundle-size GitHub Action workflow automatically.- Later once a dev version is published, the unpacked size of the CLI stays below ~16MB on npm.
- There is a tracking issue or/and an open PR to update the documentation, especially the Prisma CLI reference.
Set up a local project that will be linked to the local packages.
💡 This works best when compiling with
pnpm run watch
in the background.
cd sandbox
# Copy a template from the sandbox directory
cp -r basic-sqlite my-project
cd my-project
pnpm install
pnpm prisma -v
# 💡 In any successful setup `pnpm prisma -v` should return
# prisma : 0.0.0
# @prisma/client : 0.0.0
# ...
pnpm prisma generate
Alternatives
cd packages/cli
./src/bin.ts -v # should return the version `prisma: 0.0.0` in the output
./src/bin.ts generate # for `prisma generate`
For an overview, adding, running tests & guidelines see TESTING.md.
Tests are located under ./packages/cli/src/__tests__/
- Commands are tested in
./packages/cli/src/__tests__/commands/
- Fixtures are in
./packages/cli/src/__tests__/fixtures/
We structure our messages like this:
<type>(<package>): <subject>
<BLANK LINE>
<body>
Example
feat(client): new awesome feature
Closes #111
List of types:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
List of directories in the monorepo:
- adapter-libsql
- adapter-neon
- adapter-pg
- adapter-planetscale
- cli
- client
- debug
- driver-adapter-utils
- engines
- fetch-engine
- generator-helper
- get-platform
- instrumentation
- integration-tests
- internals
- migrate
- nextjs-monorepo-workaround-plugin
Pull Request authors must sign the Prisma CLA, it will show up in an automated comment after you create a PR.
If you cannot or do not want to sign this CLA (e.g. your employment contract for your employer may not allow this), you should not submit a PR. Open an issue and someone else can do the work.