Skip to content

Commit 498ce23

Browse files
Merge branch 'main' into main
2 parents 5f9281f + 39e0dbd commit 498ce23

File tree

65 files changed

+3070
-976
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3070
-976
lines changed

cSpell.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"Openform",
5353
"Overfetching",
5454
"pgbouncer",
55+
"elysia",
5556
"planetscale",
5657
"pooler",
5758
"poolers",
@@ -123,7 +124,8 @@
123124
"Dreamies",
124125
"Treatos",
125126
"Svetlana",
126-
"Queenie"
127+
"Queenie",
128+
"Linktree"
127129
],
128130
"ignoreWords": [
129131
"Aiven",
@@ -169,7 +171,8 @@
169171
"Sevalla's",
170172
"Dataguide",
171173
"justinellingwood",
172-
"Millis"
174+
"Millis",
175+
"Linktree"
173176
],
174177
"patterns": [
175178
{

content/200-orm/050-overview/500-databases/200-database-drivers.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ Let's assume you have `output` in your Prisma schema set to `../generated/prisma
172172
```prisma
173173
generator client {
174174
provider = "prisma-client"
175-
output = "../src/generated/client"
175+
output = "../src/generated/prisma"
176176
}
177177
```
178178

179179
You can reference Prisma Client using a relative path from your application code:
180180

181181
```ts
182-
import { PrismaClient } from '../generated/prisma/client'
182+
import { PrismaClient } from './generated/prisma/client'
183183

184184
const client = new PrismaClient()
185185
```

content/200-orm/050-overview/500-databases/300-postgresql.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,15 @@ As an example, if you want to connect to a schema called `myschema`, set the con
160160
postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=myschema&connection_limit=5&socket_timeout=3
161161
```
162162

163-
:::tip[Prisma ORM v7 connection pooling]
164-
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `pg`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
163+
:::warning[Prisma ORM v7: Connection pool defaults have changed]
164+
165+
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is now handled by the `pg` driver, which has **different defaults** than Prisma ORM v6:
166+
167+
- **Connection timeout**: `0` (no timeout) vs. v6's `5s`
168+
- **Idle timeout**: `10s` vs. v6's `300s`
169+
170+
If you experience timeout issues after upgrading, you may need to configure your driver adapter to match v6 behavior. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool#postgresql-using-the-pg-driver-adapter) for detailed configuration examples.
171+
165172
:::
166173

167174
### Configuring an SSL connection

content/200-orm/050-overview/500-databases/400-mysql.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ As an example, if you want to set the connection pool size to `5` and configure
130130
mysql://USER:PASSWORD@HOST:PORT/DATABASE?connection_limit=5&socket_timeout=3
131131
```
132132

133-
:::tip[Prisma ORM v7 connection pooling]
134-
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `mariadb`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
133+
:::warning[Prisma ORM v7: Connection pool defaults have changed]
134+
135+
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is now handled by the `mariadb` driver, which has **different defaults** than Prisma ORM v6:
136+
137+
- **Connection timeout**: `1s` vs. v6's `5s`
138+
- **Idle timeout**: `1800s` vs. v6's `300s`
139+
140+
If you experience timeout issues after upgrading, you may need to configure your driver adapter to match v6 behavior. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool#mysql-or-mariadb-using-the-mariadb-driver) for detailed configuration examples.
141+
135142
:::
136143

137144
### Configuring an SSL connection

content/200-orm/050-overview/500-databases/800-sql-server/index.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,15 @@ sqlserver://HOST[:PORT];database=DATABASE;user={MyServer/MyUser};password={ThisI
131131
| `trustServerCertificate` | No | `false` | Configures whether to trust the server certificate. |
132132
| `trustServerCertificateCA` | No | | A path to a certificate authority file to be used instead of the system certificates to authorize the server certificate. Must be either in `pem`, `crt` or `der` format. Cannot be used together with `trustServerCertificate` parameter. |
133133

134-
:::tip[Prisma ORM v7 connection pooling]
135-
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `mssql`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
134+
:::warning[Prisma ORM v7: Connection pool defaults have changed]
135+
136+
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is now handled by the `mssql` driver, which has **different defaults** than Prisma ORM v6:
137+
138+
- **Connection timeout**: `15s` vs. v6's `5s`
139+
- **Idle timeout**: `30s` vs. v6's `300s`
140+
141+
If you experience timeout issues after upgrading, you may need to configure your driver adapter to match v6 behavior. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool#sql-server-using-the-mssql-driver) for detailed configuration examples.
142+
136143
:::
137144

138145
### Using [integrated security](https://learn.microsoft.com/en-us/previous-versions/dotnet/framework/data/adonet/sql/authentication-in-sql-server) (Windows only)

content/200-orm/050-overview/500-databases/840-cockroachdb.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ model User {
9090

9191
For compatibility with existing databases, you may sometimes still need to generate a fixed sequence of integer key values. In these cases, you can use Prisma ORM's inbuilt [`sequence()`](/orm/reference/prisma-schema-reference#sequence) function for CockroachDB. For a list of available options for the `sequence()` function, see our [reference documentation](/orm/reference/prisma-schema-reference#sequence).
9292

93-
For more information on generating database keys, see CockroachDB's [Primary key best practices](https://www.cockroachlabs.com/docs/v21.2/schema-design-table#primary-key-best-practices) guide.
93+
For more information on generating database keys, see CockroachDB's [Primary key best practices](https://www.cockroachlabs.com/docs/stable/schema-design-table#select-primary-key-columns) guide.
9494

9595
## Example
9696

content/200-orm/100-prisma-schema/10-overview/04-location.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ You can do this in either of three ways:
8585
import 'dotenv/config'
8686

8787
export default defineConfig({
88-
schema: 'prisma/schema.prisma',
88+
schema: 'prisma/',
8989
migrations: {
9090
path: 'prisma/migrations',
9191
seed: 'tsx prisma/seed.ts',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ model Post {
5959
updatedAt DateTime @updatedAt
6060
published Boolean @default(false)
6161
title String @db.VarChar(255)
62-
author User? @relation(fields: [authorId], references: [id])
63-
authorId Int?
62+
author User @relation(fields: [authorId], references: [id])
63+
authorId Int
6464
}
6565
6666
enum Role {
@@ -97,7 +97,7 @@ model Post {
9797
updatedAt DateTime @updatedAt
9898
published Boolean @default(false)
9999
title String
100-
author User? @relation(fields: [authorId], references: [id])
100+
author User @relation(fields: [authorId], references: [id])
101101
authorId String @db.ObjectId
102102
}
103103

content/200-orm/100-prisma-schema/20-data-model/10-models.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ model Comment {
407407
id Int
408408
// Other fields
409409
//highlight-next-line
410-
post Post? @relation(fields: [postId], references: [id]) // A comment can have one post
411-
postId Int?
410+
post Post @relation(fields: [postId], references: [id]) // A comment can have one post
411+
postId Int
412412
}
413413
```
414414

@@ -424,11 +424,11 @@ model Post {
424424
}
425425
426426
model Comment {
427-
id String @id @default(auto()) @map("_id") @db.Objectid
427+
id String @id @default(auto()) @map("_id") @db.Objectid
428428
// Other fields
429429
//highlight-next-line
430-
post Post? @relation(fields: [postId], references: [id]) // A comment can have one post
431-
postId String? @db.ObjectId
430+
post Post @relation(fields: [postId], references: [id]) // A comment can have one post
431+
postId String @db.ObjectId
432432
}
433433
```
434434

content/200-orm/100-prisma-schema/20-data-model/30-indexes.mdx

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ You can configure indexes, unique constraints, and primary key constraints with
4242
- Available on the `@id`, `@@id`, `@unique`, `@@unique` and `@@index` attributes
4343
- SQL Server only
4444

45+
- The [`map` argument](#configuring-the-name-of-indexes-with-map) allows you to specify a custom name for the index or constraint in the underlying database
46+
- Available on the `@id`, `@@id`, `@unique`, `@@unique` and `@@index` attributes
47+
- Supported in all databases
48+
4549
See the linked sections for details of which version each feature was first introduced in.
4650

4751
### Configuring the length of indexes with `length` (MySQL)
@@ -202,9 +206,9 @@ model Example {
202206
id Int @id
203207
value Json
204208
// ^ field type matching the operator class
205-
// ^ operator class ^ index type
206209
207210
@@index([value(ops: JsonbPathOps)], type: Gin)
211+
// ^ operator class ^ index type
208212
}
209213
```
210214

@@ -340,9 +344,9 @@ model Example {
340344
id Int @id
341345
value Int
342346
// ^ field type matching the operator class
343-
// ^ operator class ^ index type
344347
345348
@@index([value(ops: Int4BloomOps)], type: Brin)
349+
// ^ operator class ^ index type
346350
}
347351
```
348352

@@ -458,6 +462,54 @@ The default value of `clustered` for each attribute is as follows:
458462

459463
A table can have at most one clustered index.
460464

465+
### Configuring the name of indexes with `map`
466+
467+
The `map` argument allows you to specify a custom name for the index or constraint in the underlying database. This is useful when you want to use a specific naming convention or when the auto-generated name doesn't meet your requirements.
468+
469+
The `map` argument is available on the `@id`, `@@id`, `@unique`, `@@unique` and `@@index` attributes.
470+
471+
As an example, the following model configures a custom name for the index on the `title` field:
472+
473+
```prisma file=schema.prisma showLineNumbers
474+
model Post {
475+
id Int @id
476+
title String
477+
478+
@@index([title], map: "my_custom_index_name")
479+
}
480+
```
481+
482+
This translates to the following SQL command (PostgreSQL example):
483+
484+
```sql
485+
CREATE INDEX "my_custom_index_name" ON "Post" ("title");
486+
```
487+
488+
Without the `map` argument, Prisma would generate a default name like `Post_title_idx`.
489+
490+
The `map` argument can also be used on unique constraints:
491+
492+
```prisma file=schema.prisma showLineNumbers
493+
model User {
494+
id Int @id
495+
email String @unique(map: "unique_user_email")
496+
}
497+
```
498+
499+
And on composite indexes and constraints:
500+
501+
```prisma file=schema.prisma showLineNumbers
502+
model Post {
503+
id Int @id
504+
title String
505+
author String
506+
createdAt DateTime
507+
508+
@@index([author, createdAt], map: "posts_author_date_idx")
509+
@@unique([title, author], map: "posts_title_author_unique")
510+
}
511+
```
512+
461513
### Upgrading from previous versions
462514

463515
:::warning

0 commit comments

Comments
 (0)