Overview

A generator can be specified via the generator block in the Prisma schema. Generators in your Prisma schema specify what assets are generated when the prisma generate command is invoked.

Fields

A generator block accepts the following fields:

NameRequiredTypeDescription
providerYesString (file path) or Enum (prisma-client-js)Describes which generator to use. This can point to a file that implements a generator or specify a built-in generator directly.
outputNoString (file path)Determines the location for the generated client, learn more. Default: node_modules/@prisma/client
binaryTargetsNoList of Enums (see below0)Specify the OS on which the Prisma Client will run to ensure binary compatibility of the query engine. Default: native

Binary targets

Prisma relies on several engine binaries. For example, Prisma Client uses the query engine binary file under the hood to communicate with a database. Prisma Migrate uses the migration engine binary file to run schema migrations against a database.

These engines are implemented in Rust and are used by Prisma in the form of executable binary files.

Being aware of the binary file is especially important when deploying your application to production!

Note: You can learn more about binary targets in the spec.

Supported operating systems

The following tables list all supported operating systems with the name of the binary file to specify in binaryTargets.

Mac OS

Build OSBuild name
Mac OSdarwin

Windows

Build OSBuild name
Windowswindows

Linux (Debian)

Build OSBuild nameOpenSSL
Debian 8 (Jessie)debian-openssl-1.0.x1.0.x
Debian 9 (Stretch)debian-openssl-1.1.x1.1.x
Debian 10 (Jessie)debian-openssl-1.1.x1.1.x

Linux (Ubuntu)

Build OSBuild nameOpenSSL
Ubuntu 14.04 (trusty)debian-openssl-1.0.x1.0.x
Ubuntu 16.04 (xenial)debian-openssl-1.0.x1.0.x
Ubuntu 18.04 (bionic)debian-openssl-1.1.x1.1.x
Ubuntu 19.04 (disco)debian-openssl-1.1.x1.1.x

Linux (CentOS)

Build OSBuild nameOpenSSL
CentOS 6rhel-openssl-1.0.x1.0.x
CentOS 7rhel-openssl-1.0.x1.0.x

Linux (Fedora)

Build OSBuild nameOpenSSL
Fedora 28rhel-openssl-1.1.x1.1.x
Fedora 29rhel-openssl-1.1.x1.1.x
Fedora 30rhel-openssl-1.1.x1.1.x

Linux (Linux Mint)

Build OSBuild nameOpenSSL
Linux Mint 18debian-openssl-1.0.x1.0.x
Linux Mint 19debian-openssl-1.1.x1.1.x

Linux (Arch Linux)

Build OSBuild nameOpenSSL
Arch Linux 2019.09.01debian-openssl-1.1.x1.1.x

The native binary target

The native binary target is special. It doesn't map to a concrete operating system. Instead, when native is specified in binaryTargets, Prisma detects the current operating system and automatically specifies the correct binary target for it.

As an example, assume you're running Mac OS and you specify the following generator:

generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}

In that case, Prisma detects your operating system and finds the right binary file for it based on the table above. As you're running Mac OS, the binary file that was compiled for darwin will be selected.

Examples

Specify the prisma-client-js generator with the default output and binaryTargets

generator client {
provider = "prisma-client-js"
}

Note that the above generator definition is equivalent to the following because it uses the default values for output and binaryTargets:

generator client {
provider = "prisma-client-js"
output = "node_modules/@prisma/client"
binaryTargets = ["native"]
}

Specify a custom output location for Prisma Client

generator client {
provider = "prisma-client-js"
output = "../src/generated/client"
}

Specify custom binaryTargets to ensure compatibility with the OS

This example shows how to configure Prisma Client to run on Ubuntu 19.04 (disco) based on the table above.

generator client {
provider = "prisma-client-js"
binaryTargets = ["debian-openssl-1.1.x"]
}

Specify a provider pointing to some custom generator implementation

This example shows how to use a custom generator that's located in a directory called my-generator.

generator client {
provider = "./my-generator"
}
Edit this page on Github