Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d6b1bb3
update docs for sql views
nikolasburk Aug 7, 2025
6547b29
Update content/200-orm/100-prisma-schema/20-data-model/40-views.mdx
nikolasburk Aug 7, 2025
07b270a
add improvements
nikolasburk Aug 7, 2025
cead47b
Merge branch 'docs/6.14.0' of github.com:prisma/docs into docs/6.14.0
nikolasburk Aug 7, 2025
d971a75
minor improvements
nikolasburk Aug 7, 2025
95620a8
minor improvements in view docs
nikolasburk Aug 7, 2025
bf51ce6
polished view docs
nikolasburk Aug 12, 2025
1d2afdc
update notes about query compiler in ga
nikolasburk Aug 15, 2025
89631fa
fix merge conflicts
nikolasburk Aug 15, 2025
604eb59
update preview feature reference
nikolasburk Aug 15, 2025
2514cca
update management api guide
nikolasburk Aug 18, 2025
1bdecb6
reworked partner oauth section
nikolasburk Aug 18, 2025
12ea903
add docs for creating oauth apps
nikolasburk Aug 18, 2025
3fad666
deprecate postgres extensions
nikolasburk Sep 2, 2025
3208b24
resolve merge conflict
nikolasburk Sep 2, 2025
03d4da0
fix remaining merge conflicts
nikolasburk Sep 2, 2025
62a4bbd
Merge branch 'main' into docs/6.16.0
nikolasburk Sep 2, 2025
be83cf2
fix remaining merge conflicts
nikolasburk Sep 2, 2025
cdf1558
Merge branch 'docs/6.16.0' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 2, 2025
caed9fb
Update content/200-orm/100-prisma-schema/80-postgresql-extensions.mdx
nikolasburk Sep 2, 2025
1569814
Update content/200-orm/100-prisma-schema/80-postgresql-extensions.mdx
nikolasburk Sep 2, 2025
fc1c971
Update content/200-orm/200-prisma-client/000-setup-and-configuration/…
nikolasburk Sep 2, 2025
fc2dee5
fix broken links
nikolasburk Sep 3, 2025
533428e
Merge branch 'docs/6.16.0' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 3, 2025
706c2ec
fix broken tab item
nikolasburk Sep 3, 2025
a438d2e
fix broken mdx
nikolasburk Sep 3, 2025
acfe3df
add docs for vs code login and direct tcp connections
nikolasburk Sep 3, 2025
206d2ed
update query compiler into ga
nikolasburk Sep 3, 2025
7b39a6e
update driver adapters into ga
nikolasburk Sep 3, 2025
751b2c7
update prisma-client generator to ga
nikolasburk Sep 3, 2025
6eb0276
add prisma-client example
nikolasburk Sep 3, 2025
7a11f13
Update content/200-orm/200-prisma-client/000-setup-and-configuration/…
nikolasburk Sep 3, 2025
a6093ed
Update content/200-orm/200-prisma-client/000-setup-and-configuration/…
nikolasburk Sep 3, 2025
23c534f
Apply suggestions from code review
nikolasburk Sep 3, 2025
41f1200
fix minor issues
nikolasburk Sep 3, 2025
119edd8
Merge branch 'docs/6.16.0' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 3, 2025
9f1a436
Merge branch 'main' into docs/6.16.0
nikolasburk Sep 3, 2025
9b98e6c
fix broken mdx
nikolasburk Sep 3, 2025
2cb83f4
Merge branch 'docs/6.16.0' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 3, 2025
80b3f79
fix links
nikolasburk Sep 3, 2025
6c0b3cc
Update content/200-orm/200-prisma-client/000-setup-and-configuration/…
nikolasburk Sep 3, 2025
edf852b
Merge branch 'main' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 9, 2025
0f373b2
Merge branch 'main' into docs/6.16.0
nikolasburk Sep 9, 2025
460bdea
minor changes
nikolasburk Sep 9, 2025
fbfaf11
Merge branch 'docs/6.16.0' of github.com:prisma/docs into docs/6.16.0
nikolasburk Sep 10, 2025
a263b4b
remove note about no login for local ppg management in vs code
nikolasburk Sep 10, 2025
506d54c
Merge branch 'main' into docs/6.16.0
nikolasburk Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ toc_max_heading_level: 4

## Default built-in drivers

One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines). The Query Engine is responsible for transforming Prisma Client queries into SQL statements. It connects to your database via TCP using built-in drivers that don't require additional setup.
One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines) (which is implemented in Rust). The Query Engine is responsible for transforming Prisma Client queries into SQL statements. It connects to your database via TCP using built-in drivers that don't require additional setup.

:::note

As of [v6.7.0](https://pris.ly/release/6.7.0), Prisma ORM has the `queryCompiler` Preview feature.
As of [v6.15.0](https://pris.ly/release/6.15.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).

**When enabled, your Prisma Client will be generated [without a Rust-based query engine binary](/orm/prisma-client/setup-and-configuration/no-rust-engine)**:
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["queryCompiler", "driverAdapters"]
provider = "prisma-client-js" // or "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
```

> Note that the [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) Preview feature is required alongside `queryCompiler`.
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.

You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.

:::

Expand Down
31 changes: 17 additions & 14 deletions content/200-orm/100-prisma-schema/10-overview/03-generators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A generator determines which assets are created when you run the `prisma generat
There are two generators for Prisma Client:

- `prisma-client-js`: Generates Prisma Client into `node_modules`
- `prisma-client` ([Preview](/orm/more/releases#preview)): Newer and more flexible version of `prisma-client-js` with ESM support; it outputs plain TypeScript code and _requires_ a custom `output` path (read more about it [here](https://www.prisma.io/blog/why-prisma-orm-generates-code-into-node-modules-and-why-it-ll-change))
- `prisma-client`: Newer and more flexible version of `prisma-client-js` with ESM support; it outputs plain TypeScript code and _requires_ a custom `output` path (read more about it [here](https://www.prisma.io/blog/why-prisma-orm-generates-code-into-node-modules-and-why-it-ll-change))

Alternatively, you can configure any npm package that complies with our generator specification.

Expand All @@ -45,20 +45,23 @@ generator client {

:::note

As of [v6.7.0](https://pris.ly/release/6.7.0), Prisma ORM has the `queryCompiler` Preview feature.
As of [v6.15.0](https://pris.ly/release/6.15.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).

**When enabled, your Prisma Client will be generated [without a Rust-based query engine binary](/orm/prisma-client/setup-and-configuration/no-rust-engine)**:
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["queryCompiler", "driverAdapters"]
provider = "prisma-client-js" // or "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
```

Note that the [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) Preview feature is required alongside `queryCompiler`.
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.

When using Prisma ORM without Rust, the `binaryTargets` field is obsolete and not needed.

When using the `queryCompiler` Preview feature, the `binaryTargets` field is obsolete and not needed.
You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.

:::

Expand All @@ -85,23 +88,23 @@ If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled

> **Note**: The `native` binary target is the default. You can set it explicitly if you wish to include additional [binary targets](/orm/reference/prisma-schema-reference#binarytargets-options) for deployment to different environments.

## `prisma-client` (Preview)
## `prisma-client`

The new `prisma-client` generator offers greater control and flexibility when using Prisma ORM across different JavaScript environments (such as ESM, Bun, Deno, ...).

It generates Prisma Client into a custom directory in your application's codebase that's specified via the `output` field on the `generator` block. This gives you full visibility and control over the generated code. It also [splits](#output-splitting-and-importing-types) the generated Prisma Client library into multiple files.

Currently in [Preview](/orm/more/releases#preview), this generator ensures you can bundle your application code exactly the way you want, without relying on hidden or automatic behaviors.
This generator ensures you can bundle your application code exactly the way you want, without relying on hidden or automatic behaviors.

Here are the main differences compared to `prisma-client-js`:

- Requires an `output` path; no magic generation into `node_modules` any more
- Does not load `.env` at run time; use `dotenv` or set environment variables manually
- Requires an `output` path; no "magic" generation into `node_modules` any more
- Doesn't load `.env` at runtime; use `dotenv` or set environment variables manually instead
- Supports ESM and CommonJS via the `moduleFormat` field
- More flexible thanks to additional fields
- More flexible thanks to additional [fields](#field-reference)
- Outputs plain TypeScript that's bundled just like the rest of your application code

The `prisma-client` generator will become the new default with Prisma ORM v7.
The `prisma-client` generator has been Generally Available since [v6.15.0](https://pris.ly/releases/6.15.0) will become the new default with Prisma ORM v7.

### Getting started

Expand Down Expand Up @@ -138,7 +141,7 @@ Then `../src/generated/prisma` places the generated code in `src/generated/prism

Generate Prisma Client by running:

```bash
```terminal
npx prisma generate
```

Expand Down
105 changes: 22 additions & 83 deletions content/200-orm/100-prisma-schema/80-postgresql-extensions.mdx
Original file line number Diff line number Diff line change
@@ -1,113 +1,52 @@
---
title: 'PostgreSQL extensions'
metaTitle: 'How to represent PostgreSQL extensions in your Prisma schema'
metaDescription: 'How to represent PostgreSQL extensions in your Prisma scheme, introspect extensions in your database, and apply changes to extensions with Prisma Migrate'
sidebar_class_name: preview-badge
metaTitle: 'How to use PostgreSQL extensions with Prisma ORM'
metaDescription: 'How to install and manage PostgreSQL extensions with Prisma ORM using customized migrations, and how to use them in Prisma Client.'
tocDepth: 3
---

This page introduces PostgreSQL extensions and describes how to represent extensions in your Prisma schema, how to introspect existing extensions in your database, and how to apply changes to your extensions to your database with Prisma Migrate.
This page is about [PostgreSQL extensions](https://www.postgresql.org/docs/current/external-extensions.html) and explains how to use them with Prisma ORM.

<Admonition type="warning">
:::warning

Support for declaring PostgreSQL extensions in your schema is available in preview for the PostgreSQL connector only in Prisma versions 4.5.0 and later.
Between Prisma ORM v4.5.0 and v6.16.0, you could enable extensions in the Prisma schema via the `postgresqlExtensions` preview feature flag. This feature flag has been deprecated in v6.16.0 and the recommended approach for using PostgreSQL extensions now is to install them via [customized migrations](/orm/prisma-migrate/workflows/customizing-migrations).

</Admonition>
:::

## What are PostgreSQL extensions?

PostgreSQL allows you to extend your database functionality by installing and activating packages known as _extensions_. For example, the `citext` extension adds a case-insensitive string data type. Some extensions, such as `citext`, are supplied directly by PostgreSQL, while other extensions are developed externally. For more information on extensions, see [the PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-createextension.html).

To use an extension, it must first be _installed_ on the local file system of your database server. You then need to _activate_ the extension, which runs a script file that adds the new functionality.

<Admonition type="info">
## Using a PostgreSQL extension with Prisma ORM

Note that PostgreSQL's documentation uses the term 'install' to refer to what we call activating an extension. We have used separate terms here to make it clear that these are two different steps.
Let's walk through an example of installing the `citext` extension.

</Admonition>
### 1. Create an empty migration

Prisma's `postgresqlExtensions` preview feature allows you to represent PostgreSQL extensions in your Prisma schema. Note that specific extensions may add functionality that is not currently supported by Prisma. For example, an extension may add a type or index that is not supported by Prisma. This functionality must be implemented on a case-by-case basis and is not provided by this preview feature.
Run the following command to create an empty migration that you can [customize](/orm/prisma-migrate/workflows/customizing-migrations):

## How to enable the `postgresqlExtensions` preview feature

Representing PostgreSQL extensions in your Prisma Schema is currently a preview feature. To enable the `postgresqlExtensions` preview feature, you will need to add the `postgresqlExtensions` feature flag to the `previewFeatures` field of the `generator` block in your Prisma schema:

```prisma file=schema.prisma highlight=3;add showLineNumbers
generator client {
provider = "prisma-client-js"
//add-next-line
previewFeatures = ["postgresqlExtensions"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
```terminal
npx prisma migrate dev --create-only
```

## How to represent PostgreSQL extensions in your Prisma schema
### 2. Add a SQL statement to install the extension

To represent PostgreSQL extensions in your Prisma schema, add the `extensions` field to the `datasource` block of your `schema.prisma` file with an array of the extensions that you require. For example, the following schema lists the `hstore`, `pg_trgm` and `postgis` extensions:
In the new migration file that was created in the `migrations` directory, add the following statement:

```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
extensions = [hstore(schema: "myHstoreSchema"), pg_trgm, postgis(version: "2.1")]
}
```sql
CREATE EXTENSION IF NOT EXISTS citext;
```

Each extension name in the Prisma schema can take the following optional arguments:

- `schema`: the name of the schema in which to activate the extension's objects. If this argument is not specified, the current default object creation schema is used.
- `version`: the version of the extension to activate. If this argument is not specified, the value given in the extension's control file is used.
- `map`: the database name of the extension. If this argument is not specified, the name of the extension in the Prisma schema must match the database name.
### 3. Deploy the migration

In the example above, the `hstore` extension uses the `myHstoreSchema` schema, and the `postgis` extension is activated with version 2.1 of the extension.
Run the following command to deploy the migration and apply to your database:

The `map` argument is useful when the PostgreSQL extension that you want to activate has a name that is not a valid identifier in the Prisma schema. For example, the `uuid-ossp` PostgreSQL extension name is an invalid identifier because it contains a hyphen. In the following example, the extension is mapped to the valid name `uuidOssp` in the Prisma schema:

```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
extensions = [uuidOssp(map: "uuid-ossp")]
}
```terminal
npx prisma migrate deploy
```

## How to introspect PostgreSQL extensions

To [introspect](/orm/prisma-schema/introspection) PostgreSQL extensions currently activated in your database and add relevant extensions to your Prisma schema, run `npx prisma db pull`.

Many PostgreSQL extensions are not relevant to the Prisma schema. For example, some extensions are intended for database administration tasks that do not change the schema. If all these extensions were included, the list of extensions would be very long. To avoid this, Prisma maintains an allowlist of known relevant extensions. The current allowlist is the following:

- [`citext`](https://www.postgresql.org/docs/current/citext.html): provides a case-insensitive character string type, `citext`
- [`pgcrypto`](https://www.postgresql.org/docs/current/pgcrypto.html): provides cryptographic functions, like `gen_random_uuid()`, to generate universally unique identifiers (UUIDs v4)
- [`uuid-ossp`](https://www.postgresql.org/docs/current/uuid-ossp.html): provides functions, like `uuid_generate_v4()`, to generate universally unique identifiers (UUIDs v4)
- [`postgis`](https://postgis.net/): adds GIS (Geographic Information Systems) support

**Note**: Since PostgreSQL v13, `gen_random_uuid()` can be used without an extension to generate universally unique identifiers (UUIDs v4).

Extensions are introspected as follows:

- The first time you introspect, all database extensions that are on the allowlist are added to your Prisma schema
- When you re-introspect, the behavior depends on whether the extension is on the allowlist or not.
- Extensions on the allowlist:
- are **added** to your Prisma schema if they are in the database but not in the Prisma schema
- are **kept** in your Prisma schema if they are in the Prisma schema and in the database
- are **removed** from your Prisma schema if they are in the Prisma schema but not the database
- Extensions not on the allowlist:
- are **kept** in your Prisma schema if they are in the Prisma schema and in the database
- are **removed** from your Prisma schema if they are in the Prisma schema but not the database

The `version` argument will not be added to the Prisma schema when you introspect.

## How to migrate PostgreSQL extensions

You can update your list of PostgreSQL extensions in your Prisma schema and apply the changes to your database with [Prisma Migrate](/orm/prisma-migrate).

This works in a similar way to migration of other elements of your Prisma schema, such as models or fields. However, there are the following differences:
### 4. Use the extension

- If you remove an extension from your schema but it is still activated on your database, Prisma Migrate will not deactivate it from the database.
- If you add a new extension to your schema, it will only be activated if it does not already exist in the database, because the extension may already have been created manually.
- If you remove the `version` or `schema` arguments from the extension definition, it has no effect to the extensions in the database in the following migrations.
You can now use the extension in your queries with Prisma Client. If the extension has special data types that currently can't be natively represented in the Prisma schema, you can still define fields of that type on your models using the [`Unsupported`](/orm/prisma-schema/data-model/models#unsupported-types) fallback type.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ Relational database connectors use Prisma ORM's own connection pool, and the Mon

:::note

As of [v6.7.0](https://pris.ly/release/6.7.0), Prisma ORM has the `queryCompiler` Preview feature.
As of [v6.15.0](https://pris.ly/release/6.15.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).

**When enabled, your Prisma Client will be generated [without a Rust-based query engine binary](/orm/prisma-client/setup-and-configuration/no-rust-engine)**:
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["queryCompiler", "driverAdapters"]
provider = "prisma-client-js" // or "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
```

Note that the [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) Preview feature is required alongside `queryCompiler`. When using the `queryCompiler` Preview feature, the connection pool is maintained by the native JS database driver you're using.
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines. In this scenario, the connection pool is maintained by the native JS database driver you're using.

You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,21 @@ If you consistently experience connection pool timeouts after configuring the re

:::note

As of [v6.7.0](https://pris.ly/release/6.7.0), Prisma ORM has the `queryCompiler` Preview feature.
As of [v6.15.0](https://pris.ly/release/6.15.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).

**When enabled, your Prisma Client will be generated [without a Rust-based query engine binary](/orm/prisma-client/setup-and-configuration/no-rust-engine)**:
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:

```prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["queryCompiler", "driverAdapters"]
provider = "prisma-client-js" // or "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
```

Note that the [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) Preview feature is required alongside `queryCompiler`. When using the `queryCompiler` Preview feature, the connection pool size is set via the native JS driver you are using.
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines. In this scenario, the connection pool size is set via the native JS driver you are using.

You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.

:::

Expand Down
Loading
Loading