Skip to content

Commit 04dd079

Browse files
authored
Merge branch 'prisma-7' into prisma-7-getting-started-restructure
2 parents ab6ee45 + 3bf085d commit 04dd079

24 files changed

Lines changed: 185 additions & 1286 deletions

File tree

.coderabbit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
22
# yaml template to refer to https://docs.coderabbit.ai/reference/yaml-template#enterprise
33
language: "en-US"
4+
tone_instructions: "You are a principal engineer with natural teaching abilities. You detect issues and clearly explain why."
45
reviews:
56
collapse_walkthrough: false
67
profile: "chill"
@@ -14,6 +15,7 @@ reviews:
1415
auto_review:
1516
enabled: true
1617
drafts: false
18+
base_branches: [".*"]
1719
finishing_touches:
1820
docstrings:
1921
enabled: false

.github/workflows/lychee.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
--cache
2626
--cache-exclude-status 429,500,502,503,504
2727
--max-cache-age 5m
28-
--verbose
2928
--no-progress
3029
--accept 200,201,204,304,403,429
3130
--timeout 20
@@ -50,7 +49,6 @@ jobs:
5049
args: >
5150
--cache
5251
--max-cache-age 5m
53-
--verbose
5452
--no-progress
5553
--accept 200,201,204,304,403,429
5654
--cache-exclude-status 429,500,502,503,504
@@ -79,8 +77,8 @@ jobs:
7977
fi
8078
8179
if [ -n "$REPORT_FILE" ]; then
82-
# Read the original output
83-
ORIGINAL=$(cat "$REPORT_FILE")
80+
# Read the original output and remove everything after 'Redirects per input'
81+
ORIGINAL=$(cat "$REPORT_FILE" | sed '/^##* Redirects per input/,$d')
8482
8583
# Create formatted output
8684
cat > lychee/formatted.md << EOF
@@ -92,7 +90,7 @@ jobs:
9290
9391
EOF
9492
95-
# Append the original content with title replacement
93+
# Append the cleaned content with title replacement
9694
echo "$ORIGINAL" | sed 's/^# Summary$//' | sed 's/^## Summary$//' >> lychee/formatted.md
9795
fi
9896

content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ metaDescription: 'Data sources enable Prisma to connect to your database. This p
66

77
A data source determines how Prisma ORM connects to your database, and is represented by the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block in the Prisma schema. The following data source uses the `postgresql` provider and includes a connection URL:
88

9+
::::note
10+
As of Prisma ORM v7, the `url`, `directUrl`, and `shadowDatabaseUrl` fields in the Prisma schema `datasource` block are deprecated. Configure these fields in [Prisma Config](/orm/reference/prisma-config-reference) instead.
11+
::::
12+
913
```prisma
1014
datasource db {
1115
provider = "postgresql"

content/200-orm/100-prisma-schema/10-overview/03-generators.mdx

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,79 +15,10 @@ generator client {
1515

1616
A generator determines which assets are created when you run the `prisma generate` command.
1717

18-
There are two generators for Prisma Client:
19-
20-
- `prisma-client` (recommended): 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))
21-
- `prisma-client-js`: Generates Prisma Client into `node_modules`
18+
The default generator for Prisma Client is `prisma-client`, which 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)).
2219

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

25-
## `prisma-client-js`
26-
27-
The `prisma-client-js` is the default generator for Prisma ORM 6.X versions and before. It requires the `@prisma/client` npm package and generates Prisma Client into `node_modules`.
28-
29-
### Field reference
30-
31-
The generator for Prisma's JavaScript Client accepts multiple additional properties:
32-
33-
- `previewFeatures`: [Preview features](/orm/reference/preview-features) to include
34-
- `binaryTargets`: Engine binary targets for `prisma-client-js` (for example, `debian-openssl-1.1.x` if you are deploying to Ubuntu 18+, or `native` if you are working locally)
35-
36-
```prisma
37-
generator client {
38-
provider = "prisma-client-js"
39-
previewFeatures = ["sample-preview-feature"]
40-
binaryTargets = ["debian-openssl-1.1.x"] // defaults to `"native"`
41-
}
42-
```
43-
44-
### Binary targets
45-
46-
:::note
47-
48-
As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).
49-
50-
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:
51-
52-
```prisma
53-
generator client {
54-
provider = "prisma-client-js" // or "prisma-client"
55-
output = "../src/generated/prisma"
56-
engineType = "client" // no Rust engine
57-
}
58-
```
59-
60-
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.
61-
62-
When using Prisma ORM without Rust, the `binaryTargets` field is obsolete and not needed.
63-
64-
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.
65-
66-
:::
67-
68-
The `prisma-client-js` generator uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform-dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s).
69-
70-
The correct file is particularly important when [deploying](/orm/prisma-client/deployment/deploy-prisma) your application to production, which often differs from your local development environment.
71-
72-
#### The `native` binary target
73-
74-
The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma Client detects the _current_ operating system and automatically specifies the correct binary target for it.
75-
76-
As an example, assume you're running **macOS** and you specify the following generator:
77-
78-
```prisma file=prisma/schema.prisma
79-
generator client {
80-
provider = "prisma-client-js"
81-
binaryTargets = ["native"]
82-
}
83-
```
84-
85-
In that case, Prisma Client detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) .
86-
If you use macOS Intel x86 (`darwin`), then the binary file that was compiled for `darwin` will be selected.
87-
If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled for `darwin-arm64` will be selected.
88-
89-
> **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.
90-
9122
## `prisma-client`
9223

9324
The new `prisma-client` generator offers greater control and flexibility when using Prisma ORM across different JavaScript environments (such as ESM, Bun, Deno, ...).
@@ -104,7 +35,7 @@ Here are the main differences compared to `prisma-client-js`:
10435
- More flexible thanks to additional [fields](#field-reference)
10536
- Outputs plain TypeScript that's bundled just like the rest of your application code
10637

107-
The `prisma-client` generator has been Generally Available since [v6.16.0](https://pris.ly/releases/6.16.0) will become the new default with Prisma ORM v7.
38+
The `prisma-client` generator has been Generally Available since [v6.16.0](https://pris.ly/releases/6.16.0) and is the default generator as of Prisma ORM v7.
10839

10940
### Getting started
11041

@@ -396,6 +327,78 @@ To see what the new `prisma-client` generator looks like in practice, check out
396327
| [`bun`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/deno-deploy) | None | None | Deno 2 | n/a |
397328
| [`deno`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/deno-deploy) | None | None | Deno 2 | n/a |
398329

330+
## `prisma-client-js` (Deprecated)
331+
332+
:::warning Deprecated
333+
334+
The `prisma-client-js` generator is **deprecated as of Prisma 7**. It was the default generator for Prisma ORM 6.X and earlier versions. We recommend migrating to [`prisma-client`](#prisma-client) for new projects and updating existing projects when possible.
335+
336+
:::
337+
338+
The `prisma-client-js` generator requires the `@prisma/client` npm package and generates Prisma Client into `node_modules`.
339+
340+
### Field reference
341+
342+
The generator for Prisma's JavaScript Client accepts multiple additional properties:
343+
344+
- `previewFeatures`: [Preview features](/orm/reference/preview-features) to include
345+
- `binaryTargets`: Engine binary targets for `prisma-client-js` (for example, `debian-openssl-1.1.x` if you are deploying to Ubuntu 18+, or `native` if you are working locally)
346+
347+
```prisma
348+
generator client {
349+
provider = "prisma-client-js"
350+
previewFeatures = ["sample-preview-feature"]
351+
binaryTargets = ["debian-openssl-1.1.x"] // defaults to `"native"`
352+
}
353+
```
354+
355+
### Binary targets
356+
357+
:::note
358+
359+
As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without Rust engines in production applications. Learn more [here](/orm/prisma-client/setup-and-configuration/no-rust-engine).
360+
361+
**When enabled, your Prisma Client will be generated without a Rust-based query engine binary**:
362+
363+
```prisma
364+
generator client {
365+
provider = "prisma-client-js" // or "prisma-client"
366+
output = "../src/generated/prisma"
367+
engineType = "client" // no Rust engine
368+
}
369+
```
370+
371+
Note that [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) are required if you want to use Prisma ORM without Rust engines.
372+
373+
When using Prisma ORM without Rust, the `binaryTargets` field is obsolete and not needed.
374+
375+
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.
376+
377+
:::
378+
379+
The `prisma-client-js` generator uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform-dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s).
380+
381+
The correct file is particularly important when [deploying](/orm/prisma-client/deployment/deploy-prisma) your application to production, which often differs from your local development environment.
382+
383+
#### The `native` binary target
384+
385+
The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma Client detects the _current_ operating system and automatically specifies the correct binary target for it.
386+
387+
As an example, assume you're running **macOS** and you specify the following generator:
388+
389+
```prisma file=prisma/schema.prisma
390+
generator client {
391+
provider = "prisma-client-js"
392+
binaryTargets = ["native"]
393+
}
394+
```
395+
396+
In that case, Prisma Client detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) .
397+
If you use macOS Intel x86 (`darwin`), then the binary file that was compiled for `darwin` will be selected.
398+
If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled for `darwin-arm64` will be selected.
399+
400+
> **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.
401+
399402
## Community generators
400403

401404
:::note

content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,35 @@ For improved compatibility with ECMAScript modules (ESM) and to ensure consisten
124124

125125
:::
126126

127+
## Loading environment variables
128+
129+
To load environment variables in your Prisma application, you can use the `prisma.config.ts` file along with the `env` helper from `prisma/config`. This approach provides better type safety and configuration management.
130+
131+
1. First, install the required dependency:
132+
133+
```bash
134+
npm install dotenv --save-dev
135+
```
136+
137+
2. Create a `.env` file in your project root (if it doesn't exist) and add your database connection string:
138+
139+
```env
140+
DATABASE_URL="your_database_connection_string_here"
141+
```
142+
143+
3. Update your `prisma.config.ts` file in your project root:
144+
145+
```ts
146+
import "dotenv/config";
147+
import { defineConfig, env } from "prisma/config";
148+
149+
export default defineConfig({
150+
datasource: {
151+
url: env("DATABASE_URL"),
152+
},
153+
});
154+
```
155+
127156
## The `@prisma/client` npm package
128157

129158
The `@prisma/client` npm package consists of two key parts:

content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ To get started, follow the [integration guide](/optimize/getting-started) and ad
4242

4343
You can also [log query events at the client level](/orm/prisma-client/observability-and-logging/logging#event-based-logging) to view the generated queries, their parameters, and execution times.
4444

45-
If you are particularly focused on monitoring query duration, consider using [logging middleware](/orm/prisma-client/client-extensions/middleware/logging-middleware).
46-
4745
:::
4846

4947
## Using bulk queries

content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Prisma Client extensions are Generally Available from versions 4.16.0 and later.
1515

1616
You can use the `query` [Prisma Client extensions](/orm/prisma-client/client-extensions) component type to hook into the query life-cycle and modify an incoming query or its result.
1717

18-
You can use Prisma Client extensions `query` component to create independent clients. This provides an alternative to [middlewares](/orm/prisma-client/client-extensions/middleware). You can bind one client to a specific filter or user, and another client to another filter or user. For example, you might do this to get [user isolation](/orm/prisma-client/client-extensions#extended-clients) in a row-level security (RLS) extension. In addition, unlike middlewares the `query` extension component gives you end-to-end type safety. [Learn more about `query` extensions versus middlewares](#query-extensions-versus-middlewares).
18+
You can use Prisma Client extensions `query` component to create independent clients with customized behavior. You can bind one client to a specific filter or user, and another client to another filter or user. For example, you might do this to get [user isolation](/orm/prisma-client/client-extensions#extended-clients) in a row-level security (RLS) extension. The `query` extension component provides end-to-end type safety for all your custom queries.
1919

2020
</TopBlock>
2121

@@ -283,20 +283,3 @@ const transactionExtension = Prisma.defineExtension((prisma) =>
283283
const prisma = new PrismaClient().$extends(transactionExtension)
284284
```
285285

286-
## Query extensions versus middlewares
287-
288-
You can use query extensions or [middlewares](/orm/prisma-client/client-extensions/middleware) to hook into the query life-cycle and modify an incoming query or its result. Client extensions and middlewares differ in the following ways:
289-
290-
- Middlewares always apply globally to the same client. Client extensions are isolated, unless you deliberately combine them. [Learn more about client extensions](/orm/prisma-client/client-extensions#about-prisma-client-extensions).
291-
- For example, in a row-level security (RLS) scenario, you can keep each user in an entirely separate client. With middlewares, all users are active in the same client.
292-
- During application execution, with extensions you can choose from one or more extended clients, or the standard Prisma Client. With middlewares, you cannot choose which client to use, because there is only one global client.
293-
- Extensions benefit from end-to-end type safety and inference, but middlewares don't.
294-
295-
You can use Prisma Client extensions in all scenarios where middlewares can be used.
296-
297-
### If you use the `query` extension component and middlewares
298-
299-
If you use the `query` extension component and middlewares in your project, then the following rules and priorities apply:
300-
301-
- In your application code, you must declare all your middlewares on the main Prisma Client instance. You cannot declare them on an extended client.
302-
- In situations where middlewares and extensions with a `query` component execute, Prisma Client executes the middlewares before it executes the extensions with the `query` component. Prisma Client executes the individual middlewares and extensions in the order in which you instantiated them with `$use` or `$extends`.

0 commit comments

Comments
 (0)