diff --git a/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx b/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx
index ea7fd22348..af317b3dad 100644
--- a/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx
+++ b/content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx
@@ -41,11 +41,11 @@ Every project that uses a tool from the Prisma ORM toolkit starts with a [Prisma
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Post {
@@ -101,10 +101,36 @@ model User {
In this schema, you configure three things:
-- **Data source**: Specifies your database connection (via an environment variable)
+- **Data source**: Specifies your database connection. Database connection URLs are configured in `prisma.config.ts`.
- **Generator**: Indicates that you want to generate Prisma Client
- **Data model**: Defines your application models
+### Configuring database connections
+
+Database connection URLs are configured in a `prisma.config.ts` file. Create a `prisma.config.ts` file in your project root:
+
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ migrations: {
+ path: 'prisma/migrations',
+ seed: 'tsx ./prisma/seed.ts',
+ },
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
+:::info
+
+When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell.
+
+:::
+
### The Prisma schema data model
On this page, the focus is on the data model. You can learn more about [Data sources](/orm/prisma-schema/overview/data-sources) and [Generators](/orm/prisma-schema/overview/generators) on the respective docs pages.
@@ -142,9 +168,9 @@ Then, you can run `prisma generate`:
npx prisma generate
```
-The `prisma generate` command reads your Prisma schema and _generates_ Prisma Client code. The code is [generated into the `node_modules/.prisma/client` folder by default](/orm/prisma-client/setup-and-configuration/generating-prisma-client#the-prismaclient-npm-package).
+The `prisma generate` command reads your Prisma schema and _generates_ Prisma Client code. The code is generated into the path specified in the `output` field of your generator block (e.g., `./generated` as shown in the schema example above).
-After you change your data model, you'll need to manually re-generate Prisma Client by running `prisma generate` to ensure the code inside `node_modules/.prisma/client` gets updated.
+After you change your data model, you'll need to manually re-generate Prisma Client by running `prisma generate` to ensure the generated code gets updated.
#### Using Prisma Client to send queries to your database
@@ -156,7 +182,7 @@ Once Prisma Client has been generated, you can import it in your code and send q
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
const prisma = new PrismaClient()
```
@@ -165,7 +191,7 @@ const prisma = new PrismaClient()
```js
-const { PrismaClient } = require('@prisma/client')
+const { PrismaClient } = require('./generated/client')
const prisma = new PrismaClient()
```
diff --git a/content/200-orm/050-overview/100-introduction/300-data-modeling.mdx b/content/200-orm/050-overview/100-introduction/300-data-modeling.mdx
index af5cd1a998..107ddf045b 100644
--- a/content/200-orm/050-overview/100-introduction/300-data-modeling.mdx
+++ b/content/200-orm/050-overview/100-introduction/300-data-modeling.mdx
@@ -211,9 +211,9 @@ export type User = {
In addition to the generated types, Prisma Client also provides a data access API that you can use once you've installed the `@prisma/client` package:
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
// or
-// const { PrismaClient } = require('@prisma/client')
+// const { PrismaClient } = require('../prisma/generated/client')
const prisma = new PrismaClient()
diff --git a/content/200-orm/050-overview/300-prisma-in-your-stack/01-rest.mdx b/content/200-orm/050-overview/300-prisma-in-your-stack/01-rest.mdx
index 5b7c5e3442..0b3c249fb0 100644
--- a/content/200-orm/050-overview/300-prisma-in-your-stack/01-rest.mdx
+++ b/content/200-orm/050-overview/300-prisma-in-your-stack/01-rest.mdx
@@ -43,7 +43,8 @@ datasource db {
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Post {
diff --git a/content/200-orm/050-overview/300-prisma-in-your-stack/03-fullstack.mdx b/content/200-orm/050-overview/300-prisma-in-your-stack/03-fullstack.mdx
index df9b99e3ed..f0942db1e5 100644
--- a/content/200-orm/050-overview/300-prisma-in-your-stack/03-fullstack.mdx
+++ b/content/200-orm/050-overview/300-prisma-in-your-stack/03-fullstack.mdx
@@ -41,7 +41,8 @@ datasource db {
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Post {
diff --git a/content/200-orm/050-overview/300-prisma-in-your-stack/04-is-prisma-an-orm.mdx b/content/200-orm/050-overview/300-prisma-in-your-stack/04-is-prisma-an-orm.mdx
index 9ae264f8c9..f642ebd85c 100644
--- a/content/200-orm/050-overview/300-prisma-in-your-stack/04-is-prisma-an-orm.mdx
+++ b/content/200-orm/050-overview/300-prisma-in-your-stack/04-is-prisma-an-orm.mdx
@@ -228,11 +228,11 @@ As an example, here's a Prisma schema for a blog:
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Post {
@@ -308,7 +308,8 @@ datasource db {
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
```
@@ -338,7 +339,8 @@ datasource db {
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Post {
@@ -380,7 +382,7 @@ So far, the article covered the concepts behind Prisma ORM, its implementation o
Accessing the database with Prisma Client happens through the query methods it exposes. All queries return plain old JavaScript objects. Given the blog schema from above, fetching a user looks as follows:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
diff --git a/content/200-orm/050-overview/500-databases/200-database-drivers.mdx b/content/200-orm/050-overview/500-databases/200-database-drivers.mdx
index 323f9ca92c..822925c2ad 100644
--- a/content/200-orm/050-overview/500-databases/200-database-drivers.mdx
+++ b/content/200-orm/050-overview/500-databases/200-database-drivers.mdx
@@ -18,7 +18,7 @@ As of [v6.15.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
+ provider = "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
@@ -102,7 +102,7 @@ Earlier versions of Prisma ORM required you to first instantiate the driver itse
```typescript
import { createClient } from '@libsql/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
// Old way of using driver adapters (before 6.6.0)
const driver = createClient({
@@ -137,7 +137,7 @@ When using Prisma ORM's built-in drivers, the connection string is read from the
On the other hand, when using a driver adapter, the connection string needs to be provided in your _application code_ when the driver adapter is set up initially. Here is how this is done for the `pg` driver and the `@prisma/adapter-pg` adapter:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { PrismaPg } from '@prisma/adapter-pg'
const adapter = new PrismaPg({ connectionString: env.DATABASE_URL })
@@ -154,7 +154,7 @@ Let's assume you had `output` in your Prisma schema set to `../src/generated/cli
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
output = "../src/generated/client"
}
```
diff --git a/content/200-orm/050-overview/500-databases/300-postgresql.mdx b/content/200-orm/050-overview/500-databases/300-postgresql.mdx
index fc4144ba28..52ead2eb8d 100644
--- a/content/200-orm/050-overview/500-databases/300-postgresql.mdx
+++ b/content/200-orm/050-overview/500-databases/300-postgresql.mdx
@@ -25,14 +25,33 @@ To connect to a PostgreSQL database server, you need to configure a [`datasource
```prisma file=schema.prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
+The database connection URL is configured in `prisma.config.ts`:
+
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
+:::info
+
+When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell.
+
+:::
+
The fields passed to the `datasource` block are:
- `provider`: Specifies the `postgresql` data source connector.
-- `url`: Specifies the [connection URL](#connection-url) for the PostgreSQL database server. In this case, an [environment variable is used](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) to provide the connection URL.
+- The `url` field is configured in `prisma.config.ts` and specifies the [connection URL](#connection-url) for the PostgreSQL database server.
## Using the `node-postgres` driver
@@ -56,7 +75,7 @@ Now, when you instantiate Prisma Client, you need to pass an instance of Prisma
```ts
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const connectionString = `${process.env.DATABASE_URL}`
@@ -105,11 +124,11 @@ The following components make up the _base URL_ of your database, they are alway
| Password | `PASSWORD` | Password for your database user |
| Database | `DATABASE` | Name of the [database](https://www.postgresql.org/docs/12/manage-ag-overview.html) you want to use, e.g. `mydb` |
-
+:::info
You must [percentage-encode special characters](/orm/reference/connection-urls#special-characters).
-
+:::
#### Arguments
diff --git a/content/200-orm/050-overview/500-databases/400-mysql.mdx b/content/200-orm/050-overview/500-databases/400-mysql.mdx
index d9b7033275..18e7214e5f 100644
--- a/content/200-orm/050-overview/500-databases/400-mysql.mdx
+++ b/content/200-orm/050-overview/500-databases/400-mysql.mdx
@@ -16,14 +16,33 @@ To connect to a MySQL database server, you need to configure a [`datasource`](/o
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
}
```
+The database connection URL is configured in `prisma.config.ts`:
+
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
+:::info
+
+When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell.
+
+:::
+
The fields passed to the `datasource` block are:
- `provider`: Specifies the `mysql` data source connector, which is used both for MySQL and MariaDB.
-- `url`: Specifies the [connection URL](#connection-url) for the MySQL database server. In this case, an [environment variable is used](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) to provide the connection URL.
+- The `url` field is configured in `prisma.config.ts` and specifies the [connection URL](#connection-url) for the MySQL database server.
## Using the `mariadb` driver
@@ -83,11 +102,11 @@ The following components make up the _base URL_ of your database, they are alway
| Password | `PASSWORD` | Password for your database user |
| Database | `DATABASE` | Name of the [database](https://dev.mysql.com/doc/refman/8.0/en/creating-database.html) you want to use, e.g. `mydb` |
-
+:::info
You must [percentage-encode special characters](/orm/reference/connection-urls#special-characters).
-
+:::
#### Arguments
diff --git a/content/200-orm/050-overview/500-databases/500-sqlite.mdx b/content/200-orm/050-overview/500-databases/500-sqlite.mdx
index db904f7aa8..1e27d3911b 100644
--- a/content/200-orm/050-overview/500-databases/500-sqlite.mdx
+++ b/content/200-orm/050-overview/500-databases/500-sqlite.mdx
@@ -46,10 +46,10 @@ npm install @prisma/adapter-better-sqlite3
Now, when you instantiate Prisma Client, you need to pass an instance of Prisma ORM's driver adapter to the `PrismaClient` constructor:
```ts
-import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3';
+import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
import { PrismaClient } from './generated/prisma';
-const adapter = new PrismaBetterSQLite3({
+const adapter = new PrismaBetterSqlite3({
url: "file:./prisma/dev.db"
});
const prisma = new PrismaClient({ adapter });
@@ -64,10 +64,10 @@ By default, driver adapters store `DateTime` values as **ISO 8601 strings**, whi
However, if you need **100% backward compatibility** with Prisma ORM's native SQLite driver (for example, when migrating an existing database), you should use the `unixepoch-ms` format, which stores timestamps as the number of milliseconds since the Unix epoch:
```ts
-import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3';
+import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
import { PrismaClient } from './generated/prisma';
-const adapter = new PrismaBetterSQLite3({
+const adapter = new PrismaBetterSqlite3({
url: "file:./prisma/dev.db"
}, {
timestampFormat: 'unixepoch-ms'
diff --git a/content/200-orm/050-overview/500-databases/600-mongodb.mdx b/content/200-orm/050-overview/500-databases/600-mongodb.mdx
index 0e519206ff..a88868ec91 100644
--- a/content/200-orm/050-overview/500-databases/600-mongodb.mdx
+++ b/content/200-orm/050-overview/500-databases/600-mongodb.mdx
@@ -12,11 +12,11 @@ codeStyle: false
This guide discusses the concepts behind using Prisma ORM and MongoDB, explains the commonalities and differences between MongoDB and other database providers, and leads you through the process for configuring your application to integrate with MongoDB using Prisma ORM.
-
+:::info
To connect Prisma ORM with MongoDB, refer to our [Getting Started documentation](/getting-started/prisma-orm/quickstart/mongodb).
-
+:::
@@ -70,11 +70,11 @@ This section provides instructions for how to carry out tasks that require steps
Migrating your database over time is an important part of the development cycle. During development, you will need to update your Prisma schema (for example, to add new fields), then update the data in your development environment’s database, and eventually push both the updated schema and the new data to the production database.
-
+:::info
When using MongoDB, be aware that the “coupling” between your schema and the database is purposefully designed to be less rigid than with SQL databases; MongoDB will not enforce the schema, so you have to verify data integrity.
-
+:::
These iterative tasks of updating the schema and the database can result in inconsistencies between your schema and the actual data in the database. Let’s look at one scenario where this can happen, and then examine several strategies for you and your team to consider for handling these inconsistencies.
@@ -385,11 +385,11 @@ The fields passed to the `datasource` block are:
- `provider`: Specifies the `mongodb` data source connector.
- `url`: Specifies the [connection URL](#connection-url) for the MongoDB server. In this case, an [environment variable is used](/orm/more/development-environment/environment-variables) to provide the connection URL.
-
+:::warning
The MongoDB database connector uses transactions to support nested writes. Transactions **require** a [replica set](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/) deployment. The easiest way to deploy a replica set is with [Atlas](https://www.mongodb.com/docs/atlas/getting-started/). It's free to get started.
-
+:::
## Connection details
@@ -417,11 +417,11 @@ The following components make up the _base URL_ of your database:
| Port | `PORT` | Port on which your database server is running, e.g. `1234`. If none is provided the default `27017` is used. |
| Database | `DATABASE` | Name of the database to use. If none is specified but the `authSource` option is set then the `authSource` database name is used. If neither the database in the connection string nor the `authSource` option is specified then it defaults to `admin` |
-
+:::info
You must [percentage-encode special characters](/orm/reference/connection-urls#special-characters).
-
+:::
#### Arguments
diff --git a/content/200-orm/050-overview/500-databases/800-sql-server/index.mdx b/content/200-orm/050-overview/500-databases/800-sql-server/index.mdx
index b118b92b32..86e02b41ac 100644
--- a/content/200-orm/050-overview/500-databases/800-sql-server/index.mdx
+++ b/content/200-orm/050-overview/500-databases/800-sql-server/index.mdx
@@ -15,14 +15,33 @@ To connect to a Microsoft SQL Server database, you need to configure a [`datasou
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "sqlserver"
- url = env("DATABASE_URL")
}
```
+The database connection URL is configured in `prisma.config.ts`:
+
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
+:::info
+
+When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell.
+
+:::
+
The fields passed to the `datasource` block are:
- `provider`: Specifies the `sqlserver` data source connector.
-- `url`: Specifies the [connection URL](#connection-details) for the Microsoft SQL Server database. In this case, an [environment variable is used](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) to provide the connection URL.
+- The `url` field is configured in `prisma.config.ts` and specifies the [connection URL](#connection-details) for the Microsoft SQL Server database.
## Using the `node-mssql` driver
@@ -47,7 +66,7 @@ Now, when you instantiate Prisma Client, you need to pass an instance of Prisma
```ts
import { PrismaMssql } from '@prisma/adapter-mssql'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const config = {
server: 'localhost',
@@ -75,7 +94,7 @@ The following example uses SQL authentication (username and password) with an en
sqlserver://HOST[:PORT];database=DATABASE;user=USER;password=PASSWORD;encrypt=true
```
-
+:::warning
Note: If you are using any of the following characters in your connection string, [you will need to escape them](https://learn.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver16#escaping-values-in-the-connection-url).
@@ -89,7 +108,7 @@ To escape these characters, use curly braces `{}` around values that contain spe
sqlserver://HOST[:PORT];database=DATABASE;user={MyServer/MyUser};password={ThisIsA:SecurePassword;};encrypt=true
```
-
+:::
### Arguments
diff --git a/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx b/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx
index ca6984dd09..beb30d2655 100644
--- a/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx
+++ b/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx
@@ -12,11 +12,11 @@ This guide discusses the concepts behind using Prisma ORM and CockroachDB, expla
-
+:::info
The CockroachDB connector is generally available in versions `3.14.0` and later. It was first added as a [Preview feature](/orm/reference/preview-features) in version [`3.9.0`](https://github.com/prisma/prisma/releases/tag/3.9.0) with support for Introspection, and Prisma Migrate support was added in [`3.11.0`](https://github.com/prisma/prisma/releases/tag/3.11.0).
-
+:::
## What is CockroachDB?
@@ -99,20 +99,39 @@ To connect to a CockroachDB database server, you need to configure a [`datasourc
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "cockroachdb"
- url = env("DATABASE_URL")
}
```
+The database connection URL is configured in `prisma.config.ts`:
+
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
+:::info
+
+When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell.
+
+:::
+
The fields passed to the `datasource` block are:
- `provider`: Specifies the `cockroachdb` data source connector.
-- `url`: Specifies the [connection URL](#connection-details) for the CockroachDB database server. In this case, an [environment variable is used](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) to provide the connection URL.
+- The `url` field is configured in `prisma.config.ts` and specifies the [connection URL](#connection-details) for the CockroachDB database server.
-
+:::info
While `cockroachdb` and `postgresql` connectors are similar, it is mandatory to use the `cockroachdb` connector instead of `postgresql` when connecting to a CockroachDB database from version 5.0.0.
-
+:::
## Connection details
diff --git a/content/200-orm/050-overview/500-databases/850-planetscale.mdx b/content/200-orm/050-overview/500-databases/850-planetscale.mdx
index d325915dc1..d642075e1e 100644
--- a/content/200-orm/050-overview/500-databases/850-planetscale.mdx
+++ b/content/200-orm/050-overview/500-databases/850-planetscale.mdx
@@ -37,11 +37,11 @@ PlanetScale's branching model and design for scalability means that there are al
- **Creating indexes on foreign keys.** When [emulating relations in Prisma ORM](#option-1-emulate-relations-in-prisma-client) (i.e. when _not_ using foreign key constraints on the database-level), you will need to create dedicated indexes on foreign keys. In a standard MySQL database, if a table has a column with a foreign key constraint, an index is automatically created on that column. When PlanetScale is configured to not use foreign key constraints, these indexes are [currently](https://github.com/prisma/prisma/issues/10611) not created when Prisma Client emulates relations, which can lead to issues with queries not being well optimized. To avoid this, you can create indexes in Prisma ORM. For more information, see [How to create indexes on foreign keys](#2-create-indexes-on-foreign-keys).
- **Making schema changes with `db push`.** When you merge a development branch into your production branch, PlanetScale will automatically compare the two schemas and generate its own schema diff. This means that Prisma ORM's [`prisma migrate`](/orm/prisma-migrate) workflow, which generates its own history of migration files, is not a natural fit when working with PlanetScale. These migration files may not reflect the actual schema changes run by PlanetScale when the branch is merged.
-
+ :::warning
We recommend not using `prisma migrate` when making schema changes with PlanetScale. Instead, we recommend that you use the `prisma db push` command.
-
+ :::
For an example of how this works, see [How to make schema changes with `db push`](#how-to-make-schema-changes-with-db-push)
@@ -70,16 +70,15 @@ To enable emulation of relations in Prisma Client, set the `relationMode` field
```prisma file=schema.prisma
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
relationMode = "prisma"
}
```
-
+:::info
The ability to set the relation mode was introduced as part of the `referentialIntegrity` preview feature in Prisma ORM version 3.1.1, and is generally available in Prisma ORM versions 4.8.0 and later.
The `relationMode` field was renamed in Prisma ORM version 4.5.0, and was previously named `referentialIntegrity`.
-
+:::
If you use relations in your Prisma schema with the default `"foreignKeys"` option for the `relationMode` field, PlanetScale will error and Prisma ORM output the [P3021 error message](/orm/reference/error-reference#p3021) when it tries to create foreign keys. (In versions before 2.27.0 it will output a raw database error.)
@@ -132,11 +131,11 @@ You can then add this change to your schema [using `db push`](#how-to-make-schem
In versions 4.7.0 and later, Prisma ORM warns you if you have a relation with no index on the relation scalar field. For more information, see [Index validation](/orm/prisma-schema/data-model/relations/relation-mode#index-validation).
-
+:::warning
One issue to be aware of is that [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations) cannot have an index added in this way. If query speed or cost is an issue, you may instead want to use an [explicit many-to-many relation](/orm/prisma-schema/data-model/relations/many-to-many-relations#explicit-many-to-many-relations) in this case.
-
+:::
### Option 2: Enable foreign key constraints in the PlanetScale database settings
@@ -269,8 +268,8 @@ In order to use the shard key attributes, you need to specify the `shardKeys` Pr
```prisma
generator client {
- provider = "prisma-client-js"
- output = "../generated/prisma"
+ provider = "prisma-client"
+ output = "./generated/prisma"
previewFeatures = ["shardKeys"]
}
```
@@ -336,7 +335,7 @@ Update your Prisma Client instance to use the PlanetScale serverless driver:
```ts
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/prisma/client'
import dotenv from 'dotenv'
import { fetch as undiciFetch } from 'undici'
diff --git a/content/200-orm/050-overview/500-databases/880-supabase.mdx b/content/200-orm/050-overview/500-databases/880-supabase.mdx
index 9f338d42d4..b17558b8fa 100644
--- a/content/200-orm/050-overview/500-databases/880-supabase.mdx
+++ b/content/200-orm/050-overview/500-databases/880-supabase.mdx
@@ -64,19 +64,16 @@ You can then update your `schema.prisma` to use the new direct URL:
```prisma file=schema.prisma highlight=4;add showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
- //add-next-line
- directUrl = env("DIRECT_URL")
}
```
More information about the `directUrl` field can be found [here](/orm/reference/prisma-schema-reference#fields).
-
+:::info
We strongly recommend using connection pooling with Supavisor in addition to `DIRECT_URL`. You will gain the great developer experience of the Prisma CLI while also allowing for connections to be pooled regardless of your deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling.
-
+:::
## Getting started with Supabase
diff --git a/content/200-orm/050-overview/500-databases/890-neon.mdx b/content/200-orm/050-overview/500-databases/890-neon.mdx
index d5be0b9d74..046bc1674d 100644
--- a/content/200-orm/050-overview/500-databases/890-neon.mdx
+++ b/content/200-orm/050-overview/500-databases/890-neon.mdx
@@ -63,19 +63,16 @@ You can then update your `schema.prisma` to use the new direct URL:
```prisma file=schema.prisma highlight=4;add showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
- //add-next-line
- directUrl = env("DIRECT_URL")
}
```
More information about the `directUrl` field can be found [here](/orm/reference/prisma-schema-reference#fields).
-
+:::info
We strongly recommend using the pooled connection string in your `DATABASE_URL` environment variable. You will gain the great developer experience of the Prisma CLI while also allowing for connections to be pooled regardless of deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling.
-
+:::
## Resolving connection timeouts
@@ -129,7 +126,7 @@ npm install @prisma/adapter-neon
Update your Prisma Client instance:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { PrismaNeon } from '@prisma/adapter-neon'
import dotenv from 'dotenv'
diff --git a/content/200-orm/050-overview/500-databases/900-turso.mdx b/content/200-orm/050-overview/500-databases/900-turso.mdx
index df54ae82b0..0408350fd3 100644
--- a/content/200-orm/050-overview/500-databases/900-turso.mdx
+++ b/content/200-orm/050-overview/500-databases/900-turso.mdx
@@ -92,7 +92,7 @@ npm install @prisma/adapter-libsql
Update your Prisma Client instance:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
const adapter = new PrismaLibSQL({
diff --git a/content/200-orm/050-overview/600-beyond-prisma-orm.mdx b/content/200-orm/050-overview/600-beyond-prisma-orm.mdx
index bcb0a883e0..d3640fb297 100644
--- a/content/200-orm/050-overview/600-beyond-prisma-orm.mdx
+++ b/content/200-orm/050-overview/600-beyond-prisma-orm.mdx
@@ -33,7 +33,7 @@ Scale to millions of queries per day without infrastructure changes. Efficiently
Accelerate integrates seamlessly with your Prisma ORM project through the `@prisma/extension-accelerate` client extension. Get started quickly with our [setup guide](/accelerate/getting-started) and instantly access full edge environment support, connection pooling, and global caching.
```tsx
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'
// 1. Extend your Prisma Client with the Accelerate extension
diff --git a/content/200-orm/100-prisma-schema/10-overview/index.mdx b/content/200-orm/100-prisma-schema/10-overview/index.mdx
index 447ed608e5..462d421657 100644
--- a/content/200-orm/100-prisma-schema/10-overview/index.mdx
+++ b/content/200-orm/100-prisma-schema/10-overview/index.mdx
@@ -37,11 +37,11 @@ The following is an example of a Prisma Schema that specifies:
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model User {
@@ -144,7 +144,6 @@ Environment variables can be accessed using the `env()` function:
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
diff --git a/content/200-orm/100-prisma-schema/20-data-model/10-models.mdx b/content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
index f8b2711c3e..381faa1962 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
@@ -20,11 +20,11 @@ The following schema describes a blogging platform - the data model definition i
```prisma highlight=10-46;normal
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
//highlight-start
@@ -189,7 +189,7 @@ const user = await prisma.user.create({
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient({})
@@ -679,11 +679,11 @@ model User {
The `firstName_lastName` field will now be named `fullName` instead.
-
+:::info
Refer to the documentation on [working with composite IDs](/orm/prisma-client/special-fields-and-types/working-with-composite-ids-and-constraints) to learn how to interact with a composite ID in Prisma Client.
-
+:::
##### `@unique` fields as unique identifiers
@@ -700,12 +700,12 @@ model User {
}
```
-
+:::info
**Constraint names in relational databases**
You can optionally define a [custom primary key constraint name](/orm/prisma-schema/data-model/database-mapping#constraint-and-index-names) in the underlying database.
-
+:::
#### Defining IDs in MongoDB
@@ -739,12 +739,12 @@ model User {
}
```
-
+:::warning
**MongoDB does not support `@@id`**
MongoDB does not support composite IDs, which means you cannot identify a model with a `@@id` block.
-
+:::
### Defining a default value
@@ -799,11 +799,11 @@ Default values can be:
- [Functions](#using-functions), such as [`now()`](/orm/reference/prisma-schema-reference#now) or [`uuid()`](/orm/reference/prisma-schema-reference#uuid)
- JSON data. Note that JSON needs to be enclosed with double-quotes inside the `@default` attribute, e.g.: `@default("[]")`. If you want to provide a JSON object, you need to enclose it with double-quotes and then escape any internal double quotes using a backslash, e.g.: `@default("{ \"hello\": \"world\" }")`.
-
+:::info
Refer to the [attribute function reference documentation](/orm/reference/prisma-schema-reference#attribute-functions) for information about connector support for functions.
-
+:::
### Defining a unique field
@@ -877,12 +877,12 @@ model Post {
-
+:::info
**Constraint names in relational databases**
You can optionally define a [custom unique constraint name](/orm/prisma-schema/data-model/database-mapping#constraint-and-index-names) in the underlying database.
-
+:::
By default, the name of this field in Prisma Client queries will be `authorId_title`.
@@ -905,11 +905,11 @@ model Post {
The `authorId_title` field will now be named `authorTitle` instead.
-
+:::info
Refer to the documentation on [working with composite unique identifiers](/orm/prisma-client/special-fields-and-types/working-with-composite-ids-and-constraints) to learn how to interact with a composite unique constraints in Prisma Client.
-
+:::
#### Composite type unique constraints
@@ -966,12 +966,12 @@ model Post {
}
```
-
+:::info
**Index names in relational databases**
You can optionally define a [custom index name](/orm/prisma-schema/data-model/database-mapping#constraint-and-index-names) in the underlying database.
-
+:::
#### Defining composite type indexes
@@ -1067,17 +1067,17 @@ enum Role {
## Defining composite types
-
+:::info
Composite types were added in version `3.10.0` under the `mongodb` Preview feature flag and are in General Availability since version `3.12.0`.
-
+:::
-
+:::warning
Composite types are currently only available on MongoDB.
-
+:::
Composite types (known as [embedded documents](https://www.mongodb.com/docs/manual/data-modeling/#embedded-data) in MongoDB) provide support for embedding records inside other records, by allowing you to define new object types. Composite types are structured and typed in a similar way to [models](#defining-models).
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/100-one-to-one-relations.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/100-one-to-one-relations.mdx
index 4d92e087ae..35fbb79f3d 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/100-one-to-one-relations.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/100-one-to-one-relations.mdx
@@ -102,11 +102,11 @@ model Profile {
-
+:::warning
In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma ORM versions 4.0.0 and later, if you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.
-
+:::
## Multi-field relations in relational databases
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/200-one-to-many-relations.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/200-one-to-many-relations.mdx
index 3472d120d9..080681c7d4 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/200-one-to-many-relations.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/200-one-to-many-relations.mdx
@@ -100,11 +100,11 @@ model Post {
-
+:::warning
In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma ORM versions 4.0.0 and later, if you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.
-
+:::
## Multi-field relations in relational databases
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/300-many-to-many-relations.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/300-many-to-many-relations.mdx
index 587c78fbbe..d90f6a1fc9 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/300-many-to-many-relations.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/300-many-to-many-relations.mdx
@@ -347,11 +347,11 @@ Implicit m-n relations:
- You cannot use a [multi-field ID](/orm/reference/prisma-schema-reference#id-1)
- You cannot use a `@unique` in place of an `@id`
-
+ :::info
To use either of these features, you must use an [explicit m-n instead](#explicit-many-to-many-relations).
-
+ :::
#### Conventions for relation tables in implicit m-n relations
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/index.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/index.mdx
index bbef7dc445..8d3a16d497 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/index.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/index.mdx
@@ -11,7 +11,7 @@ Referential actions determine what happens to a record when your application del
From version 2.26.0, you can define referential actions on the relation fields in your Prisma schema. This allows you to define referential actions like cascading deletes and cascading updates at a Prisma ORM level.
-
+:::info
**Version differences**
@@ -19,7 +19,7 @@ From version 2.26.0, you can define referential actions on the relation fields i
- If you use a version between 2.26.0 and 3.0.0, you can use referential actions as described on this page, but you must [enable the preview feature flag](/orm/reference/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature) `referentialActions`.
- If you use version 2.25.0 or earlier, you can configure cascading deletes manually in your database.
-
+:::
In the following example, adding `onDelete: Cascade` to the `author` field on the `Post` model means that deleting the `User` record will also delete all related `Post` records.
@@ -50,12 +50,12 @@ If you do not specify a referential action, Prisma ORM [uses a default](#referen
-
+:::danger
If you upgrade from a version earlier than 2.26.0:
It is extremely important that you check the [upgrade paths for referential actions](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-3/referential-actions) section. Prisma ORM's support of referential actions **removes the safety net in Prisma Client that prevents cascading deletes at runtime**. If you use the feature _without upgrading your database_, the [old default action](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-3/referential-actions#prisma-orm-2x-default-referential-actions) - `ON DELETE CASCADE` - becomes active. This might result in cascading deletes that you did not expect.
-
+:::
## What are referential actions?
@@ -265,11 +265,11 @@ model User {
`User`s with posts **cannot** be deleted. The `User`'s `id` **cannot** be changed.
-
+:::warning
The `Restrict` action is **not** available on [Microsoft SQL Server](/orm/overview/databases/sql-server) and triggers a schema validation error. Instead, you can use [`NoAction`](#noaction), which produces the same result and is compatible with SQL Server.
-
+:::
### `NoAction`
@@ -281,11 +281,11 @@ The `NoAction` action is similar to `Restrict`, the difference between the two i
- **SQL Server**: When a referenced record is deleted or modified, an error is raised. See [the SQL Server docs](https://learn.microsoft.com/en-us/sql/relational-databases/tables/graph-edge-constraints?view=sql-server-ver15#on-delete-referential-actions-on-edge-constraints) for more information.
- **MongoDB** (in preview from version 3.6.0): When a record is modified or deleted, nothing is done to any related records.
-
+:::warning
If you are [managing relations in Prisma Client](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode) rather than using foreign keys in the database, you should be aware that currently Prisma ORM only implements the referential actions. Foreign keys also create constraints, which make it impossible to manipulate data in a way that would violate these constraints: instead of executing the query, the database responds with an error. These constraints will not be created if you emulate referential integrity in Prisma Client, so if you set the referential action to `NoAction` there will be no checks to prevent you from breaking the referential integrity.
-
+:::
#### Example usage
@@ -389,11 +389,11 @@ When you run an Introspection, Prisma ORM compares all the foreign keys in the d
After introspecting, you can review the non-default clauses in your schema. The most important clause to review is `onDelete`, which defaults to `Cascade` in 2.25.0 and earlier.
-
+:::warning
If you are using either the [`delete()`](/orm/prisma-client/queries/crud#delete-a-single-record) or [`deleteMany()`](/orm/prisma-client/queries/crud#delete-all-records) methods, **[cascading deletes](#how-to-use-cascading-deletes) will now be performed** as the `referentialActions` preview feature **removed the safety net in Prisma Client that previously prevented cascading deletes at runtime**. Be sure to check your code and make any adjustments accordingly.
-
+:::
Make sure you are happy with every case of `onDelete: Cascade` in your schema. If not, either:
@@ -426,12 +426,12 @@ model User {
When running a [Migration](/orm/prisma-migrate) (or the [`prisma db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) command) the [new defaults](#referential-action-defaults) will be applied to your database.
-
+:::info
Unlike when you run an Introspect for the first time, the new referential actions clause and property, will **not** automatically be added to your prisma schema by the Prisma VSCode extension.
You will have to manually add them if you wish to use anything other than the new defaults.
-
+:::
Explicitly defining referential actions in your Prisma schema is optional. If you do not explicitly define a referential action for a relation, Prisma ORM uses the [new defaults](#referential-action-defaults).
@@ -472,7 +472,7 @@ Prior to upgrading and enabling the referential actions **preview feature**, the
> "The change you are trying to make would violate the required relation '\{relation_name}' between the \{model_a_name\} and \{model_b_name\} models."
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -500,7 +500,7 @@ To make sure you are checking for the correct errors in your code, modify your c
> "Foreign key constraint failed on the field: \{field_name\}"
```ts highlight=14;delete|15;add
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/420-relation-mode.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/420-relation-mode.mdx
index 99aa146c36..cb4c8092f6 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/420-relation-mode.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/420-relation-mode.mdx
@@ -75,11 +75,11 @@ In this case, the foreign key constraint on the `authorId` column of the `Post`
Some databases, such as MongoDB or [PlanetScale](/orm/overview/databases/planetscale#differences-to-consider), do not support foreign keys. Additionally, in some cases developers may prefer not to use foreign keys in their relational database that usually does support foreign keys. For these situations, Prisma ORM offers [the `prisma` relation mode](#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode), which emulates some properties of relations in relational databases. When you use Prisma Client with the `prisma` relation mode enabled, the behavior of queries is identical or similar, but referential actions and some constraints are handled by the Prisma engine rather than in the database.
-
+:::warning
There are performance implications to emulation of referential integrity and
referential actions in Prisma Client. In cases where the underlying database
supports foreign keys, it is usually the preferred choice.
-
+:::
## How to set the relation mode in your Prisma schema
@@ -88,17 +88,16 @@ To set the relation mode, add the `relationMode` field in the `datasource` block
```prisma file=schema.prisma highlight=4,9;add showLineNumbers
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
//add-next-line
relationMode = "prisma"
}
```
-
+:::info
The ability to set the relation mode was introduced as part of the `referentialIntegrity` preview feature in Prisma ORM version 3.1.1, and is generally available in Prisma ORM versions 4.8.0 and later.
The `relationMode` field was renamed in Prisma ORM version 4.5.0, and was previously named `referentialIntegrity`.
-
+:::
For relational databases, the available options are:
@@ -107,11 +106,11 @@ For relational databases, the available options are:
For MongoDB, the only available option is the `prisma` relation mode. This mode is also active if no `relationMode` is explicitly set in the `datasource` block.
-
+:::warning
If you switch between relation modes, Prisma ORM will add or remove foreign keys to your database next time you apply changes to your schema with Prisma Migrate or `db push`. See [Switch between relation modes](#switch-between-relation-modes) for more information.
-
+:::
## Handle relations in your relational database with the `foreignKeys` relation mode
@@ -147,12 +146,12 @@ The `prisma` relation mode emulates some foreign key constraints and referential
The `prisma` relation mode is the default option for the MongoDB connector. It should also be set if you use a relational database that does not support foreign keys. For example, [if you use PlanetScale](/orm/overview/databases/planetscale#option-1-emulate-relations-in-prisma-client) without foreign key constraints, you should use the `prisma` relation mode.
-
+:::warning
There are performance implications to emulation of referential integrity in
Prisma Client, because it uses additional database queries to maintain
referential integrity. In cases where the underlying database can handle
referential integrity with foreign keys, it is usually the preferred choice.
-
+:::
Emulation of relations is only available for Prisma Client queries and does not apply to raw queries.
@@ -213,7 +212,6 @@ If you do not add the index manually, queries might require full table scans. Th
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
relationMode = "prisma"
}
diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
index 74653921e4..40caa28bd8 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/index.mdx
@@ -299,17 +299,17 @@ model Category {
-
+:::info
This schema is the same as the [example data model](/orm/prisma-schema/data-model/models) but has all [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields) removed (except for the required [relation scalar fields](/orm/prisma-schema/data-model/relations#relation-scalar-fields)) so you can focus on the [relation fields](#relation-fields).
-
+:::
-
+:::info
This example uses [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations). These relations do not require the `@relation` attribute unless you need to [disambiguate relations](#disambiguating-relations).
-
+:::
Notice that the syntax is slightly different between relational databases and MongoDB - particularly for [many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations).
diff --git a/content/200-orm/100-prisma-schema/20-data-model/30-indexes.mdx b/content/200-orm/100-prisma-schema/20-data-model/30-indexes.mdx
index 66ac00544d..b1891cbe30 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/30-indexes.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/30-indexes.mdx
@@ -11,11 +11,11 @@ Prisma ORM allows configuration of database indexes, unique constraints and prim
Version `3.6.0` also introduces support for introspection and migration of full text indexes in MySQL and MongoDB through a new `@@fulltext` attribute, available through the `fullTextIndex` Preview feature.
-
+:::warning
If you are upgrading from a version earlier than 4.0.0, these changes to index configuration and full text indexes might be **breaking changes** if you have a database that already uses these features. See [Upgrading from previous versions](#upgrading-from-previous-versions) for more information on how to upgrade.
-
+:::
@@ -189,11 +189,11 @@ The GIN index stores composite values, such as arrays or `JsonB` data. This is u
An indexed field can define the operator class, which defines the operators handled by the index.
-
+:::warning
Indexes using a function (such as `to_tsvector`) to determine the indexed value are not yet supported by Prisma ORM. Indexes defined in this way will not be visible with `prisma db pull`.
-
+:::
As an example, the following model adds a `Gin` index to the `value` field, with `JsonbPathOps` as the class of operators allowed to use the index:
@@ -460,11 +460,11 @@ A table can have at most one clustered index.
### Upgrading from previous versions
-
+:::warning
These index configuration changes can be **breaking changes** when activating the functionality for certain, existing Prisma schemas for existing databases. After enabling the preview features required to use them, run `prisma db pull` to introspect the existing database to update your Prisma schema before using Prisma Migrate again.
-
+:::
A breaking change can occur in the following situations:
@@ -479,11 +479,11 @@ In each of the cases above unwanted changes to your database can be prevented by
The `fullTextIndex` preview feature provides support for introspection and migration of full text indexes in MySQL and MongoDB in version 3.6.0 and later. This can be configured using the `@@fulltext` attribute. Existing full text indexes in the database are added to your Prisma schema after introspecting with `db pull`, and new full text indexes added in the Prisma schema are created in the database when using Prisma Migrate. This also prevents validation errors in some database schemas that were not working before.
-
+:::warning
For now we do not enable the full text search commands in Prisma Client for MongoDB; the progress can be followed in the [MongoDB](https://github.com/prisma/prisma/issues/9413) issue.
-
+:::
### Enabling the `fullTextIndex` preview feature
@@ -491,7 +491,8 @@ To enable the `fullTextIndex` preview feature, add the `fullTextIndex` feature f
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["fullTextIndex"]
}
```
@@ -534,10 +535,10 @@ model Post {
### Upgrading from previous versions
-
+:::warning
This can be a **breaking change** when activating the functionality for certain, existing Prisma schemas for existing databases. After enabling the preview features required to use them, run `prisma db pull` to introspect the existing database to update your Prisma schema before using Prisma Migrate again.
-
+:::
Earlier versions of Prisma ORM converted full text indexes using the `@@index` attribute rather than the `@@fulltext` attribute. After enabling the `fullTextIndex` preview feature, run `prisma db pull` to convert these indexes to `@@fulltext` before migrating again with Prisma Migrate. If you do not do this, the existing indexes will be dropped instead and normal indexes will be created in their place.
diff --git a/content/200-orm/100-prisma-schema/20-data-model/40-views.mdx b/content/200-orm/100-prisma-schema/20-data-model/40-views.mdx
index ab3467c8dd..f2c479674f 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/40-views.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/40-views.mdx
@@ -31,6 +31,7 @@ Support for views is currently in an early preview. To enable the `views` previe
```prisma file=schema.prisma highlight=3;add showLineNumbers
generator client {
provider = "prisma-client"
+ output = "./generated"
//add-next-line
previewFeatures = ["views"]
}
diff --git a/content/200-orm/100-prisma-schema/20-data-model/50-database-mapping.mdx b/content/200-orm/100-prisma-schema/20-data-model/50-database-mapping.mdx
index 0bd8d6550c..87fa788746 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/50-database-mapping.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/50-database-mapping.mdx
@@ -80,11 +80,11 @@ You can optionally use the `map` argument to explicitly define the **underlying
When introspecting a database, the `map` argument will _only_ be rendered in the schema if the name _differs_ from Prisma ORM's [default constraint naming convention for indexes and constraints](#prisma-orms-default-naming-conventions-for-indexes-and-constraints).
-
+:::danger
If you use Prisma Migrate in a version earlier than 2.29.0 and want to maintain your existing constraint and index names after upgrading to a newer version, **do not** immediately run `prisma migrate` or `prisma db push`. This will **change any underlying constraint name that does not follow Prisma ORM's convention**. Follow the [upgrade path that allows you to maintain existing constraint and index names](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-3/named-constraints#option-1-i-want-to-maintain-my-existing-constraint-and-index-names).
-
+:::
### Use cases for named constraints
diff --git a/content/200-orm/100-prisma-schema/20-data-model/60-multi-schema.mdx b/content/200-orm/100-prisma-schema/20-data-model/60-multi-schema.mdx
index 213aca8ec7..6c8568acbe 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/60-multi-schema.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/60-multi-schema.mdx
@@ -28,11 +28,11 @@ To use multiple database schemas in your Prisma schema file, add the names of yo
```prisma file=schema.prisma
generator client {
provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//add-next-line
schemas = ["base", "shop"]
}
diff --git a/content/200-orm/100-prisma-schema/20-data-model/65-externally-managed-tables.mdx b/content/200-orm/100-prisma-schema/20-data-model/65-externally-managed-tables.mdx
index bf14f9c00f..f5dfaf0e10 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/65-externally-managed-tables.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/65-externally-managed-tables.mdx
@@ -137,7 +137,8 @@ Assume you have the following Prisma schema which only contains the `posts` tabl
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
// ...
}
diff --git a/content/200-orm/100-prisma-schema/20-data-model/70-unsupported-database-features.mdx b/content/200-orm/100-prisma-schema/20-data-model/70-unsupported-database-features.mdx
index 5c5476d85c..cc27bd16c3 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/70-unsupported-database-features.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/70-unsupported-database-features.mdx
@@ -58,18 +58,19 @@ In Prisma ORM versions 4.5.0 and later, you can then activate the extension by d
```prisma file=schema.prisma highlight=3,9;add showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
//add-next-line
previewFeatures = ["postgresqlExtensions"]
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//add-next-line
extensions = [pgcrypto]
}
```
+```
In earlier versions of Prisma ORM, you must instead run a SQL command to activate the extension:
diff --git a/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx b/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx
index 5824300c6b..e3aad67fde 100644
--- a/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx
+++ b/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx
@@ -141,7 +141,7 @@ When querying for videos and articles like that, TypeScript will still only reco
If you want to have type safety for these objects, you need to define dedicated types for them. You can do this, for example, by using the generated `Activity` type and the TypeScript `Omit` utility type to remove properties from it:
```ts
-import { Activity } from '@prisma/client'
+import { Activity } from '../prisma/generated/client'
type Video = Omit
type Article = Omit
@@ -272,7 +272,7 @@ import {
Video as VideoDB,
Article as ArticleDB,
Activity,
-} from '@prisma/client'
+} from '../prisma/generated/client'
type Video = Omit
type Article = Omit
@@ -281,7 +281,7 @@ type Article = Omit
Once these types are defined, you can define mapping functions to convert the types you receive from the queries above into the desired `Video` and `Article` types. Here's the example for the `Video` type:
```ts
-import { Prisma, Video as VideoDB, Activity } from '@prisma/client'
+import { Prisma, Video as VideoDB, Activity } from '../prisma/generated/client'
type Video = Omit
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/005-introduction.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/005-introduction.mdx
index 99beeecfb0..972efafea5 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/005-introduction.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/005-introduction.mdx
@@ -46,12 +46,11 @@ In order to set up Prisma Client, you need a [Prisma schema file](/orm/prisma-sc
```prisma file=schema.prisma
datasource db {
- url = env("DATABASE_URL")
provider = "postgresql"
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
output = "../src/generated/prisma"
}
@@ -154,15 +153,15 @@ const newUser = await prisma.user.create({
const users = await prisma.user.findMany()
```
-
+:::info
All Prisma Client methods return an instance of [`PrismaPromise`](/orm/reference/prisma-client-reference#prismapromise-behavior) which only executes when you call `await` or `.then()` or `.catch()`.
-
+:::
### 5. Evolving your application
-Whenever you make changes to your database that are reflected in the Prisma schema, you need to manually re-generate Prisma Client to update the generated code in the `node_modules/.prisma/client` directory:
+Whenever you make changes to your database that are reflected in the Prisma schema, you need to manually re-generate Prisma Client to update the generated code in your output directory:
```
prisma generate
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx
index 8e7d257bf2..daa48991e7 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/010-generating-prisma-client.mdx
@@ -18,7 +18,8 @@ If Prisma ORM's Rust engine binaries cause large bundle sizes, slow builds, or d
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
+ provider = "prisma-client"
+ output = "./generated"
engineType = "client"
}
```
@@ -49,14 +50,14 @@ To generate and instantiate Prisma Client:
```prisma
generator client {
- provider = "prisma-client-js"
- output = "app/generated/prisma/client"
+ provider = "prisma-client"
+ output = "./generated"
}
```
:::note
- Feel free to customize the output location to match your application. Common directories are `app`, `src`, or even the root of your project.
+ Feel free to customize the output location to match your application. Common directories are `prisma`, `src`, or even the root of your project.
:::
@@ -69,13 +70,13 @@ To generate and instantiate Prisma Client:
1. Generate Prisma Client with the following command:
```terminal
- prisma generate
+ npx prisma generate
```
1. You can now [instantiate Prisma Client](/orm/prisma-client/setup-and-configuration/instantiate-prisma-client) in your code:
```ts
- import { PrismaClient } from 'app/generated/prisma/client'
+ import { PrismaClient } from './prisma/generated/client'
const prisma = new PrismaClient()
// use `prisma` in your application to read and write data in your DB
```
@@ -100,8 +101,8 @@ You can also specify a custom `output` path on the `generator` configuration, fo
```prisma
generator client {
- provider = "prisma-client-js"
- output = "../src/generated/client"
+ provider = "prisma-client"
+ output = "../src/generated/"
}
```
@@ -147,6 +148,10 @@ To load environment variables in your Prisma application, you can use the `prism
import { defineConfig, env } from "prisma/config";
export default defineConfig({
+ schema: "prisma/schema.prisma",
+ migrations: {
+ path: "prisma/migrations"
+ },
datasource: {
url: env("DATABASE_URL"),
},
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/015-instantiate-prisma-client.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/015-instantiate-prisma-client.mdx
index 5b913ccb38..48da945dac 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/015-instantiate-prisma-client.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/015-instantiate-prisma-client.mdx
@@ -12,7 +12,7 @@ The following example demonstrates how to import and instantiate your [generated
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
```
@@ -22,7 +22,7 @@ const prisma = new PrismaClient()
```js
-const { PrismaClient } = require('@prisma/client')
+const { PrismaClient } = require('../prisma/generated/client')
const prisma = new PrismaClient()
```
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/100-connection-management.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/100-connection-management.mdx
index 241f4a247b..a3722e27f9 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/100-connection-management.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/100-connection-management.mdx
@@ -67,7 +67,7 @@ One scenario where you should call `$disconnect()` explicitly is where a script:
The following script creates a new instance of `PrismaClient`, performs a task, and then disconnects - which closes the connection pool:
```ts highlight=19;normal
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
const emailService = new EmailService()
@@ -94,11 +94,11 @@ If the above script runs multiple times in the context of a long-running applica
## Exit hooks
-
+:::info
From Prisma ORM 5.0.0, the `beforeExit` hook only applies to the [binary Query Engine](/orm/more/under-the-hood/engines#configuring-the-query-engine).
-
+:::
The `beforeExit` hook runs when Prisma ORM is triggered externally (e.g. via a `SIGINT` signal) to shut down, and allows you to run code _before_ Prisma Client disconnects - for example, to issue queries as part of a graceful shutdown of a service:
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/115-connection-pool.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/115-connection-pool.mdx
index ba25506e73..24ca0d50ee 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/115-connection-pool.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/115-connection-pool.mdx
@@ -29,7 +29,7 @@ As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
+ provider = "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
@@ -96,7 +96,7 @@ For example, consider the following Prisma Client instance and invocation:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient({
log: ['info'],
@@ -121,11 +121,11 @@ prisma:info Starting a postgresql pool with 21 connections.
When the `PrismaClient` class was instantiated, the logging notified `stdout` that a connection pool with 21 connections was started.
-
+:::warning
Note that the output generated by `log: ['info']` can change in any release without notice. Be aware of this in case you are relying on the output in your application or a tool that you're building.
-
+:::
If you need even more insights into the size of your connection pool and the amount of in-use and idle connection, you can use the [metrics](/orm/prisma-client/observability-and-logging/metrics) feature (which is currently in Preview).
@@ -135,7 +135,7 @@ Consider the following example:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -193,11 +193,11 @@ main()
-
+:::info
For more details on what is available in the metrics output, see the [About metrics](/orm/prisma-client/observability-and-logging/metrics#about-metrics) section.
-
+:::
### Connection pool timeout
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/index.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/index.mdx
index 4f9daf7d74..d94e3e2e48 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/index.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/index.mdx
@@ -14,11 +14,11 @@ Databases can handle a limited number of concurrent connections. Each connection
The way your application **manages connections** also impacts performance. This guide describes how to approach connection management in [serverless environments](#serverless-environments-faas) and [long-running processes](#long-running-processes).
-
+:::warning
This guide focuses on **relational databases** and how to configure and tune the Prisma ORM connection pool (MongoDB uses the MongoDB driver connection pool).
-
+:::
@@ -61,7 +61,7 @@ In **long-running** applications, we recommend that you:
To re-use a single instance, create a module that exports a `PrismaClient` object:
```ts file=client.ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
let prisma = new PrismaClient()
@@ -93,7 +93,7 @@ Frameworks like [Next.js](https://nextjs.org/) support hot reloading of changed
As a workaround, you can store `PrismaClient` as a global variable in development environments only, as global variables are not reloaded:
```ts file=client.ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }
@@ -223,7 +223,7 @@ If the `connection_limit` is 1, this function is forced to send queries **serial
Instantiate `PrismaClient` [outside the scope of the function handler](https://github.com/prisma/e2e-tests/blob/5d1041d3f19245d3d237d959eca94d1d796e3a52/platforms/serverless-lambda/index.ts#L3) to increase the chances of reuse. As long as the handler remains 'warm' (in use), the connection is potentially reusable:
```ts highlight=3;normal
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const client = new PrismaClient()
@@ -273,7 +273,7 @@ As of [v6.16.0](https://pris.ly/release/6.16.0), Prisma ORM can be used without
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
+ provider = "prisma-client"
output = "../src/generated/prisma"
engineType = "client" // no Rust engine
}
@@ -353,7 +353,6 @@ You can then update your `schema.prisma` to use the new direct URL:
```prisma file=schema.prisma highlight=4;add showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//add-next-line
directUrl = env("DIRECT_URL")
}
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx
index ef695f72d3..619d0a798d 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx
@@ -26,7 +26,7 @@ Initialize the extension by extending your Prisma Client instance and provide th
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { readReplicas } from '@prisma/extension-read-replicas'
const prisma = new PrismaClient().$extends(
diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/300-no-rust-engine.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/300-no-rust-engine.mdx
index a23c2016fd..348a0e6fc3 100644
--- a/content/200-orm/200-prisma-client/000-setup-and-configuration/300-no-rust-engine.mdx
+++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/300-no-rust-engine.mdx
@@ -100,7 +100,7 @@ Finally, instantiate Prisma Client which you can do using the driver adapter and
```typescript
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
@@ -108,16 +108,16 @@ const prisma = new PrismaClient({ adapter })
```typescript
-import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3';
-import { PrismaClient } from './generated/prisma';
+import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
+import { PrismaClient } from '../generated/prisma/client';
-const adapter = new PrismaBetterSQLite3({ url: process.env.DATABASE_URL })
+const adapter = new PrismaBetterSqlite3({ url: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter });
```
```typescript
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'
export interface Env {
@@ -141,7 +141,7 @@ export default {
```typescript
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
-import { PrismaClient } from './generated/prisma';
+import { PrismaClient } from '../generated/prisma/client';
const adapter = new PrismaMariaDb({
host: "localhost",
@@ -154,7 +154,7 @@ const prisma = new PrismaClient({ adapter });
```typescript
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
import { fetch as undiciFetch } from 'undici'
const adapter = new PrismaPlanetScale({ url: process.env.DATABASE_URL, fetch: undiciFetch })
@@ -164,7 +164,7 @@ const prisma = new PrismaClient({ adapter })
```typescript
import { PrismaMSSQL } from '@prisma/adapter-mssql';
-import { PrismaClient } from './generated/prisma';
+import { PrismaClient } from '../generated/prisma/client';
const sqlConfig = {
user: process.env.DB_USER,
@@ -189,7 +189,7 @@ const prisma = new PrismaClient({ adapter });
```typescript
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
@@ -197,7 +197,7 @@ const prisma = new PrismaClient({ adapter })
```typescript
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
import { PrismaNeon } from '@prisma/adapter-neon'
import dotenv from 'dotenv'
@@ -241,7 +241,7 @@ npx prisma generate
Import and instantiate Prisma Client with the Accelerate extension:
```typescript
-import { PrismaClient } from "./generated/prisma";
+import { PrismaClient } from "../generated/prisma/client";
import { withAccelerate } from "@prisma/extension-accelerate";
const prisma = new PrismaClient().$extends(withAccelerate());
@@ -268,7 +268,7 @@ Usage of the new architecture requires the `driverAdapters` and `queryCompiler`
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js" // or `prisma-client`
+ provider = "prisma-client"
previewFeatures = ["queryCompiler", "driverAdapters"]
output = "../generated/prisma"
}
@@ -337,7 +337,7 @@ Finally, you need to instantiate Prisma Client which you can do using the driver
```typescript
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
@@ -345,16 +345,16 @@ const prisma = new PrismaClient({ adapter })
```typescript
-import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3';
-import { PrismaClient } from './generated/prisma';
+import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
+import { PrismaClient } from '../generated/prisma/client';
-const adapter = new PrismaBetterSQLite3({ url: process.env.DATABASE_URL })
+const adapter = new PrismaBetterSqlite3({ url: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter });
```
```typescript
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../generated/prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'
export interface Env {
@@ -378,7 +378,7 @@ export default {
```typescript
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
-import { PrismaClient } from './generated/prisma';
+import { PrismaClient } from '../generated/prisma/client';
const adapter = new PrismaMariaDb({
host: "localhost",
@@ -391,7 +391,7 @@ const prisma = new PrismaClient({ adapter });
```typescript
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../generated/prisma/client'
import { fetch as undiciFetch } from 'undici'
const adapter = new PrismaPlanetScale({ url: process.env.DATABASE_URL, fetch: undiciFetch })
@@ -401,7 +401,7 @@ const prisma = new PrismaClient({ adapter })
```typescript
import { PrismaMSSQL } from '@prisma/adapter-mssql';
-import { PrismaClient } from './generated/prisma';
+import { PrismaClient } from '../generated/prisma/client';
const sqlConfig = {
user: process.env.DB_USER,
@@ -426,7 +426,7 @@ const prisma = new PrismaClient({ adapter });
```typescript
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '../generated/prisma/client'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
@@ -434,7 +434,7 @@ const prisma = new PrismaClient({ adapter })
```typescript
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../generated/prisma/client'
import { PrismaNeon } from '@prisma/adapter-neon'
import dotenv from 'dotenv'
diff --git a/content/200-orm/200-prisma-client/100-queries/030-crud.mdx b/content/200-orm/200-prisma-client/100-queries/030-crud.mdx
index 09dba52754..81c9d1a780 100644
--- a/content/200-orm/200-prisma-client/100-queries/030-crud.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/030-crud.mdx
@@ -32,11 +32,11 @@ All examples are based on the following schema:
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model ExtendedProfile {
@@ -191,7 +191,7 @@ The user's `id` is auto-generated, and your schema determines [which fields are
The following example produces an identical result, but creates a `UserCreateInput` variable named `user` _outside_ the context of the `create()` query. After completing a simple check ("Should posts be included in this `create()` query?"), the `user` variable is passed into the query:
```ts
-import { PrismaClient, Prisma } from '@prisma/client'
+import { PrismaClient, Prisma } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -260,11 +260,11 @@ const createMany = await prisma.user.createMany({
-
+:::warning
Note `skipDuplicates` is not supported when using MongoDB, SQLServer, or SQLite.
-
+:::
`createMany()` uses a single `INSERT INTO` statement with multiple values, which is generally more efficient than a separate `INSERT` per row:
@@ -788,19 +788,19 @@ const upsertUser = await prisma.user.upsert({
-
+:::info
From version 4.6.0, Prisma Client carries out upserts with database native SQL commands where possible. [Learn more](/orm/reference/prisma-client-reference#database-upserts).
-
+:::
Prisma Client does not have a `findOrCreate()` query. You can use `upsert()` as a workaround. To make `upsert()` behave like a `findOrCreate()` method, provide an empty `update` parameter to `upsert()`.
-
+:::warning
A limitation to using `upsert()` as a workaround for `findOrCreate()` is that `upsert()` will only accept unique model fields in the `where` condition. So it's not possible to use `upsert()` to emulate `findOrCreate()` if the `where` condition contains non-unique fields.
-
+:::
### Update a number field
@@ -867,11 +867,11 @@ Be aware that this query will fail if the user has any related records (such as
### Cascading deletes (deleting related records)
-
+:::warning
In [2.26.0](https://github.com/prisma/prisma/releases/tag/2.26.0) and later it is possible to do cascading deletes using the **preview feature** [referential actions](/orm/prisma-schema/data-model/relations/referential-actions).
-
+:::
The following query uses [`delete()`](/orm/reference/prisma-client-reference#delete) to delete a single `User` record:
diff --git a/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx b/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
index 7a8fab2b4f..daffbf41a1 100644
--- a/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/037-relation-queries.mdx
@@ -30,7 +30,8 @@ Because the `relationLoadStrategy` option is currently in Preview, you need to e
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["relationJoins"]
}
```
diff --git a/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx b/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx
index 813f6605b6..2953162267 100644
--- a/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/050-filtering-and-sorting.mdx
@@ -11,11 +11,11 @@ Prisma Client supports [filtering](#filtering) with the `where` query option, an
Prisma Client allows you to filter records on any combination of model fields, [including related models](#filter-on-relations), and supports a variety of [filter conditions](#filter-conditions-and-operators).
-
+:::warning
Some filter conditions use the SQL operators `LIKE` and `ILIKE` which may cause unexpected behavior in your queries. Please refer to [our filtering FAQs](#filtering-faqs) for more information.
-
+:::
The following query:
@@ -394,7 +394,8 @@ This feature is further explain in [the PostgreSQL documentation](https://www.po
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["fullTextSearchPostgres"]
}
```
diff --git a/content/200-orm/200-prisma-client/100-queries/056-aggregation-grouping-summarizing.mdx b/content/200-orm/200-prisma-client/100-queries/056-aggregation-grouping-summarizing.mdx
index c0695ef1ab..76a8e709af 100644
--- a/content/200-orm/200-prisma-client/100-queries/056-aggregation-grouping-summarizing.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/056-aggregation-grouping-summarizing.mdx
@@ -350,11 +350,11 @@ const userCount = await prisma.user.count()
### Count relations
-
+:::info
This feature is generally available in version [3.0.1](https://github.com/prisma/prisma/releases/3.0.1) and later. To use this feature in versions before 3.0.1 the [Preview feature](/orm/reference/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature) `selectRelationCount` will need to be enabled.
-
+:::
To return a count of relations (for example, a user's post count), use the `_count` parameter with a nested `select` as shown:
@@ -491,11 +491,11 @@ const usersWithCount = await prisma.user.findMany({
#### Filter the relation count
-
+:::info
This feature is generally available in version `4.16.0` and later. To use this feature in versions [`4.3.0`](https://github.com/prisma/prisma/releases/tag/4.3.0) to [`4.15.0`](https://github.com/prisma/prisma/releases/tag/4.15.0) the [Preview feature](/orm/reference/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature) `filteredRelationCount` will need to be enabled.
-
+:::
Use `where` to filter the fields returned by the `_count` output type. You can do this on [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields), [relation fields](/orm/prisma-schema/data-model/models#relation-fields) and fields of a [composite type](/orm/prisma-schema/data-model/models#defining-composite-types).
diff --git a/content/200-orm/200-prisma-client/100-queries/058-transactions.mdx b/content/200-orm/200-prisma-client/100-queries/058-transactions.mdx
index 63b93505b5..7f717070a9 100644
--- a/content/200-orm/200-prisma-client/100-queries/058-transactions.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/058-transactions.mdx
@@ -13,11 +13,11 @@ A database transaction refers to a sequence of read/write operations that are _g
## Transactions overview
-
+:::info
Before Prisma ORM version 4.4.0, you could not set isolation levels on transactions. The isolation level in your database configuration always applied.
-
+:::
Developers take advantage of the safety guarantees provided by the database by wrapping the operations in a transaction. These guarantees are often summarized using the ACID acronym:
@@ -199,23 +199,23 @@ await prisma.$transaction(
Sometimes you need more control over what queries execute within a transaction. Interactive transactions are meant to provide you with an escape hatch.
-
+:::info
Interactive transactions have been generally available from version 4.7.0.
If you use interactive transactions in preview from version 2.29.0 to 4.6.1 (inclusive), you need to add the `interactiveTransactions` preview feature to the generator block of your Prisma schema.
-
+:::
To use interactive transactions, you can pass an async function into [`$transaction`](#transaction-api).
The first argument passed into this async function is an instance of Prisma Client. Below, we will call this instance `tx`. Any Prisma Client call invoked on this `tx` instance is encapsulated into the transaction.
-
+:::warning
**Use interactive transactions with caution**. Keeping transactions open for a long time hurts database performance and can even cause deadlocks. Try to avoid performing network requests and executing slow queries inside your transaction functions. We recommend you get in and out as quick as possible!
-
+:::
#### Example
@@ -235,7 +235,7 @@ In the example below, Alice and Bob each have $100 in their account. If they try
Alice is expected to be able to make 1 transfer for $100 while the other transfer would be rejected. This would result in Alice having $0 and Bob having $200.
```tsx
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
function transfer(from: string, to: string, amount: number) {
@@ -336,21 +336,21 @@ const prisma = new PrismaClient({
### Transaction isolation level
-
+:::info
This feature is not available on MongoDB, because MongoDB does not support isolation levels.
-
+:::
You can set the transaction [isolation level](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels) for transactions.
-
+:::info
This is available in the following Prisma ORM versions for interactive transactions from version 4.2.0, for sequential operations from version 4.4.0.
In versions before 4.2.0 (for interactive transactions), or 4.4.0 (for sequential operations), you cannot configure the transaction isolation level at a Prisma ORM level. Prisma ORM does not explicitly set the isolation level, so the [isolation level configured in your database](#database-specific-information-on-isolation-levels) is used.
-
+:::
#### Set the isolation level
@@ -428,12 +428,12 @@ CockroachDB and SQLite only support the `Serializable` isolation level.
### Transaction timing issues
-
+:::info
- The solution in this section does not apply to MongoDB, because MongoDB does not support [isolation levels](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels).
- The timing issues discussed in this section do not apply to CockroachDB and SQLite, because these databases only support the highest `Serializable` isolation level.
-
+:::
When two or more transactions run concurrently in certain [isolation levels](https://www.prisma.io/dataguide/intro/database-glossary#isolation-levels), timing issues can cause write conflicts or deadlocks, such as the violation of unique constraints. For example, consider the following sequence of events where Transaction A and Transaction B both attempt to execute a `deleteMany` and a `createMany` operation:
@@ -453,7 +453,7 @@ To avoid transaction write conflicts and deadlocks on a transaction:
2. In your application code, add a retry around your transaction to handle any P2034 errors, as shown in this example:
```ts
- import { Prisma, PrismaClient } from '@prisma/client'
+ import { Prisma, PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
async function main() {
@@ -1170,13 +1170,13 @@ If a ❌ conflict occurs (someone else has changed the record since you read it)
This section describes how to build your own optimistic concurrency control. See also: Plans for [application-level optimistic concurrency control on GitHub](https://github.com/prisma/prisma/issues/4988)
-
+:::info
- If you use version 4.4.0 or earlier, you cannot use optimistic concurrency control on `update` operations, because you cannot filter on non-unique fields. The `version` field you need to use with optimistic concurrency control is a non-unique field.
- Since version 5.0.0 you are able to [filter on non-unique fields in `update` operations](/orm/reference/prisma-client-reference#filter-on-non-unique-fields-with-userwhereuniqueinput) so that optimistic concurrency control is being used. The feature was also available via the Preview flag `extendedWhereUnique` from versions 4.5.0 to 4.16.2.
-
+:::
#### When to use optimistic concurrency control
@@ -1324,7 +1324,7 @@ In the example below, Alice and Bob each have $100 in their account. If they try
The expected outcome would be for Alice to make 1 transfer for $100 and the other transfer would be rejected. This would result in Alice having $0 and Bob having $200.
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
async function transfer(from: string, to: string, amount: number) {
@@ -1378,14 +1378,14 @@ If the application encounters an error along the way, the async function will th
You can learn more about interactive transactions in this [section](#interactive-transactions).
-
+:::warning
**Use interactive transactions with caution**. Keeping transactions
open for a long time hurts database performance and can even cause deadlocks.
Try to avoid performing network requests and executing slow queries inside your
transaction functions. We recommend you get in and out as quick as possible!
-
+:::
## Conclusion
diff --git a/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx b/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx
index ef473c95b8..814a66938a 100644
--- a/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx
@@ -21,7 +21,8 @@ The full-text search API is currently a Preview feature. To enable this feature,
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["fullTextSearchPostgres"]
}
```
@@ -165,11 +166,11 @@ For the full range of supported operations, see the [MySQL full text search docu
## Sorting results by `_relevance`
-
+:::warning
Sorting by relevance is only available for PostgreSQL and MySQL.
-
+:::
In addition to [Prisma Client's default `orderBy` behavior](/orm/reference/prisma-client-reference#orderby), full-text search also adds sorting by relevance to a given string or strings. As an example, if you wanted to order posts by their relevance to the term `'database'` in their title, you could use the following:
@@ -199,7 +200,8 @@ In the following example, one full text index is added to the `content` field of
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Blog {
diff --git a/content/200-orm/200-prisma-client/100-queries/061-custom-validation.mdx b/content/200-orm/200-prisma-client/100-queries/061-custom-validation.mdx
index ecc05879aa..959781b8db 100644
--- a/content/200-orm/200-prisma-client/100-queries/061-custom-validation.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/061-custom-validation.mdx
@@ -19,18 +19,18 @@ You can use any validation library you'd like. The Node.js ecosystem offers a nu
This example adds runtime validation when creating and updating values using a Zod schema to check that the data passed to Prisma Client is valid.
-
+:::warning
Query extensions do not currently work for nested operations. In this example, validations are only run on the top level data object passed to methods such as `prisma.product.create()`. Validations implemented this way do not automatically run for [nested writes](/orm/prisma-client/queries/relation-queries#nested-writes).
-
+:::
```ts copy
-import { PrismaClient, Prisma } from '@prisma/client'
+import { PrismaClient, Prisma } from '../prisma/generated/client'
import { z } from 'zod'
/**
@@ -114,11 +114,11 @@ main()
```prisma copy
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model Product {
diff --git a/content/200-orm/200-prisma-client/100-queries/062-computed-fields.mdx b/content/200-orm/200-prisma-client/100-queries/062-computed-fields.mdx
index a923a0aff8..d1f525afb8 100644
--- a/content/200-orm/200-prisma-client/100-queries/062-computed-fields.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/062-computed-fields.mdx
@@ -19,7 +19,7 @@ The following example illustrates how to create a [Prisma Client extension](/orm
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient().$extends({
result: {
@@ -68,11 +68,11 @@ main()
```prisma copy
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model User {
diff --git a/content/200-orm/200-prisma-client/100-queries/064-custom-models.mdx b/content/200-orm/200-prisma-client/100-queries/064-custom-models.mdx
index 4d5a576e1f..a51ed1c994 100644
--- a/content/200-orm/200-prisma-client/100-queries/064-custom-models.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/064-custom-models.mdx
@@ -24,7 +24,7 @@ The following example demonstrates how to create a Prisma Client extension that
```tsx
import bcrypt from 'bcryptjs'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient().$extends({
model: {
@@ -67,11 +67,11 @@ async function main() {
```prisma file="prisma/schema.prisma" copy
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
model User {
diff --git a/content/200-orm/200-prisma-client/100-queries/070-case-sensitivity.mdx b/content/200-orm/200-prisma-client/100-queries/070-case-sensitivity.mdx
index c1bc22a362..8a7ce985d0 100644
--- a/content/200-orm/200-prisma-client/100-queries/070-case-sensitivity.mdx
+++ b/content/200-orm/200-prisma-client/100-queries/070-case-sensitivity.mdx
@@ -24,11 +24,11 @@ If you use the MongoDB connector, [Prisma Client](/orm/prisma-client/queries) us
## Database collation and case sensitivity
-
+:::info
In the context of Prisma Client, the following section refers to relational database connectors only.
-
+:::
Collation specifies how data is **sorted and compared** in a database, which includes casing. Collation is something you choose when you set up a database.
diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx
index 5f3b7cb471..ab961eb88d 100644
--- a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx
+++ b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx
@@ -42,6 +42,7 @@ To start using TypedSQL in your Prisma project, follow these steps:
Starting with Prisma 6.12.0, you can configure a custom location for your SQL files using the Prisma config file. Create a `prisma.config.ts` file in your project root and specify the `typedSql.path` option:
```typescript title="prisma.config.ts"
+ import 'dotenv/config'
import { defineConfig } from 'prisma/config'
export default defineConfig({
diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx
index e0ff6126d1..557e2b0b73 100644
--- a/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx
+++ b/content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx
@@ -59,11 +59,11 @@ const email = "emelie@prisma.io";
const result = await prisma.$queryRaw(Prisma.sql`SELECT * FROM User WHERE email = ${email}`);
```
-
+:::warning
If you use string building to incorporate untrusted input into queries passed to this method, then you open up the possibility for SQL injection attacks. SQL injection attacks can expose your data to modification or deletion. The preferred mechanism would be to include the text of the query at the point that you run this method. For more information on this risk and also examples of how to prevent it, see the [SQL injection prevention](#sql-injection-prevention) section below.
-
+:::
#### Considerations
@@ -182,13 +182,13 @@ Note that if you use `$queryRawUnsafe` in conjunction with user inputs, you risk
The `$queryRawUnsafe()` method allows you to pass a raw string (or template string) to the database.
-
+:::warning
If you use this method with user inputs (in other words, `SELECT * FROM table WHERE columnx = ${userInput}`), then you open up the possibility for SQL injection attacks. SQL injection attacks can expose your data to modification or deletion.
Wherever possible you should use the `$queryRaw` method instead. When used correctly `$queryRaw` method is significantly safer but note that the `$queryRaw` method can also be made vulnerable in certain circumstances. For more information, see the [SQL injection prevention](#sql-injection-prevention) section below.
-
+:::
The following query returns all fields for each record in the `User` table:
@@ -234,11 +234,11 @@ const result: number =
await prisma.$executeRaw`UPDATE User SET active = ${active} WHERE emailValidated = ${emailValidated};`;
```
-
+:::warning
If you use string building to incorporate untrusted input into queries passed to this method, then you open up the possibility for SQL injection attacks. SQL injection attacks can expose your data to modification or deletion. The preferred mechanism would be to include the text of the query at the point that you run this method. For more information on this risk and also examples of how to prevent it, see the [SQL injection prevention](#sql-injection-prevention) section below.
-
+:::
#### Considerations
@@ -292,13 +292,13 @@ $executeRaw(query: TemplateStringsArray | Prisma.Sql, ...values: an
The `$executeRawUnsafe()` method allows you to pass a raw string (or template string) to the database. Like `$executeRaw`, it does **not** return database records, but returns the number of rows affected.
-
+:::warning
If you use this method with user inputs (in other words, `SELECT * FROM table WHERE columnx = ${userInput}`), then you open up the possibility for SQL injection attacks. SQL injection attacks can expose your data to modification or deletion.
Wherever possible you should use the `$executeRaw` method instead. When used correctly `$executeRaw` method is significantly safer but note that the `$executeRaw` method can also be made vulnerable in certain circumstances. For more information, see the [SQL injection prevention](#sql-injection-prevention) section below.
-
+:::
The following example uses a template string to update records in the database. It then returns a count of the number of records that were updated:
@@ -333,14 +333,14 @@ $executeRawUnsafe(query: string, ...values: any[]): PrismaPromise
+:::info
**Feature availability:**
- In v3.14.x and v3.15.x, raw query type mapping was available with the preview feature `improvedQueryRaw`. We made raw query type mapping [Generally Available](/orm/more/releases#generally-available-ga) in version 4.0.0, so you do not need to use `improvedQueryRaw` in version 4.0.0 or later.
- Before version 4.0.0, raw query type mapping was not available for SQLite.
-
+:::
As an example, take a raw query that selects columns with `BigInt`, `Bytes`, `Decimal` and `Date` types from a table:
diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx
index a899de290a..8ea9723ded 100644
--- a/content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx
+++ b/content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx
@@ -44,20 +44,20 @@ If you haven't already, enable the `postgresqlExtensions` Preview feature and ad
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
//add-next-line
previewFeatures = ["postgresqlExtensions"]
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//add-next-line
extensions = [postgis]
}
```
-
+:::warning
If you are not using a hosted database provider, you will likely need to install the `postgis` extension. Refer to [PostGIS's docs](http://postgis.net/documentation/getting_started/#installing-postgis) to learn more about how to get started with PostGIS. If you're using Docker Compose, you can use the following snippet to set up a PostgreSQL database that has PostGIS installed:
@@ -78,7 +78,7 @@ volumes:
db_data:
```
-
+:::
Next, create a migration and execute a migration to enable the extension:
diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/057-composite-types.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/057-composite-types.mdx
index fb67569058..0d6b0b6c56 100644
--- a/content/200-orm/200-prisma-client/200-special-fields-and-types/057-composite-types.mdx
+++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/057-composite-types.mdx
@@ -7,11 +7,11 @@ tocDepth: 3
-
+:::warning
Composite types are only available with MongoDB.
-
+:::
[Composite types](/orm/prisma-schema/data-model/models#defining-composite-types), known as [embedded documents](https://www.mongodb.com/docs/manual/data-modeling/#embedded-data) in MongoDB, allow you to embed records within other records.
@@ -322,11 +322,11 @@ const product = prisma.product.findFirst({
## Creating records with composite types using `create` and `createMany`
-
+:::info
-When you create a record with a composite type that has a unique restraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
+When you create a record with a composite type that has a unique constraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
-
+:::
Composite types can be created within a `create` or `createMany` method using the `set` operation. For example, you can use `set` within `create` to create an `Address` composite type inside an `Order`:
@@ -462,11 +462,11 @@ const product = await prisma.product.createMany({
## Changing composite types within `update` and `updateMany`
-
+:::info
-When you update a record with a composite type that has a unique restraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
+When you update a record with a composite type that has a unique constraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
-
+:::
Composite types can be set, updated or removed within an `update` or `updateMany` method. The following section describes the operations available for updating a single type or multiple types at once, and gives examples of each.
@@ -629,11 +629,11 @@ const product = prisma.product.update({
## Upserting composite types with `upsert`
-
+:::info
-When you create or update the values in a composite type that has a unique restraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
+When you create or update the values in a composite type that has a unique constraint, note that MongoDB does not enforce unique values inside a record. [Learn more](#duplicate-values-in-unique-fields-of-composite-types).
-
+:::
To create or update a composite type, use the `upsert` method. You can use the same composite operations as the `create` and `update` methods above.
diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/080-null-and-undefined.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/080-null-and-undefined.mdx
index 6af305057d..8fa599d870 100644
--- a/content/200-orm/200-prisma-client/200-special-fields-and-types/080-null-and-undefined.mdx
+++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/080-null-and-undefined.mdx
@@ -23,7 +23,8 @@ To enable this feature, add the following to your Prisma schema:
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["strictUndefinedChecks"]
}
```
@@ -234,11 +235,11 @@ const users = await prisma.user.findMany()
This query will select every row from the `User` table.
-
+:::info
-**Note**: Using `undefined` as the value of any key in a Prisma Client query's parameter object will cause Prisma ORM to act as if that key was not provided at all.
+Using `undefined` as the value of any key in a Prisma Client query's parameter object will cause Prisma ORM to act as if that key was not provided at all.
-
+:::
Although this section's examples focused on the `findMany` function, the same concepts apply to any function that can affect multiple records, such as `updateMany` and `deleteMany`.
@@ -246,11 +247,11 @@ Although this section's examples focused on the `findMany` function, the same co
This section will cover how `undefined` and `null` values affect the behavior of queries that interact with or create a single record in a database.
-
+:::warning
-**Note**: `null` is not a valid filter value in a `findUnique()` query.
+`null` is not a valid filter value in a `findUnique()` query.
-
+:::
The query behavior when using `null` and `undefined` in the filter criteria of a query that affects a single record is very similar to the behaviors described in the previous section.
diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/100-working-with-json-fields.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/100-working-with-json-fields.mdx
index ad796c8c04..131008b323 100644
--- a/content/200-orm/200-prisma-client/200-special-fields-and-types/100-working-with-json-fields.mdx
+++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/100-working-with-json-fields.mdx
@@ -142,13 +142,13 @@ const getUsers = await prisma.user.findMany({
You can also filter rows by the data inside a `Json` field. We call this **advanced `Json` filtering**. This functionality is supported by [PostgreSQL](/orm/overview/databases/postgresql) and [MySQL](/orm/overview/databases/mysql) only with [different syntaxes for the `path` option](#path-syntax-depending-on-database).
-
+:::warning
PostgreSQL does not support [filtering on object key values in arrays](#filtering-on-object-key-value-inside-array).
-
+:::
-
+:::info
The availability of advanced `Json` filtering depends on your Prisma version:
@@ -156,7 +156,7 @@ The availability of advanced `Json` filtering depends on your Prisma version:
- From v2.23.0, but before v4.0.0: advanced `Json` filtering is a [preview feature](/orm/reference/preview-features/client-preview-features). Add `previewFeatures = ["filterJson"]` to your schema. [Learn more](/orm/reference/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature).
- Before v2.23.0: you can [filter on the exact `Json` field value](#filter-on-exact-field-value), but you cannot use the other features described in this section.
-
+:::
### `path` syntax depending on database
@@ -430,11 +430,11 @@ const getUsers = await prisma.user.findMany({
})
```
-
+:::info
-**Note**: In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
+In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
-
+:::
@@ -488,11 +488,11 @@ const getUsers = await prisma.user.findMany({
})
```
-
+:::info
-**Note**: In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
+In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
-
+:::
@@ -654,11 +654,11 @@ const getUsers = await prisma.user.findMany({
Depending on your provider, you can filter on the key value of an object inside an array.
-
+:::warning
Filtering on object key values within an array is **only** supported by the [MySQL database connector](/orm/overview/databases/mysql). However, you can still [filter on the presence of entire JSON objects](#json-object-arrays).
-
+:::
In the following example, the value of `extendedPetsData` is an array of objects with a nested `insurances` array, which contains two objects:
@@ -886,19 +886,19 @@ To differentiate between these possibilities, we've introduced three _null enums
- `DbNull`: Represents the `NULL` value in the database.
- `AnyNull`: Represents both `null` JSON values and `NULL` database values. (Only when filtering)
-
+:::info
From v4.0.0, `JsonNull`, `DbNull`, and `AnyNull` are objects. Before v4.0.0, they were strings.
-
+:::
-
+:::info
- When filtering using any of the _null enums_ you can not use a shorthand and leave the `equals` operator off.
- These _null enums_ do not apply to MongoDB because there the difference between a JSON `null` and a database `NULL` does not exist.
- The _null enums_ do not apply to the `array_contains` operator in all databases because there can only be a JSON `null` within a JSON array. Since there cannot be a database `NULL` within a JSON array, `{ array_contains: null }` is not ambiguous.
-
+:::
For example:
@@ -968,11 +968,11 @@ prisma.log.findMany({
})
```
-
+:::info
These _null enums_ do not apply to MongoDB because MongoDB does not differentiate between a JSON `null` and a database `NULL`. They also do not apply to the `array_contains` operator in all databases because there can only be a JSON `null` within a JSON array. Since there cannot be a database `NULL` within a JSON array, `{ array_contains: null }` is not ambiguous.
-
+:::
## Typed `Json` Fields
@@ -986,7 +986,8 @@ Prisma's `Json` fields are untyped by default. To add strong typing, you can use
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
generator json {
diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/200-working-with-scalar-lists-arrays.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/200-working-with-scalar-lists-arrays.mdx
index 6682d03c9d..ec198230d8 100644
--- a/content/200-orm/200-prisma-client/200-special-fields-and-types/200-working-with-scalar-lists-arrays.mdx
+++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/200-working-with-scalar-lists-arrays.mdx
@@ -59,12 +59,12 @@ const createdUser = await prisma.user.create({
## Unsetting the value of a scalar list
-
+:::warning
This method is available on MongoDB only in versions
[3.11.1](https://github.com/prisma/prisma/releases/tag/3.11.1) and later.
-
+:::
The following example demonstrates how to [`unset`](/orm/reference/prisma-client-reference#unset) the value of a scalar list (`coinflips`):
@@ -83,7 +83,7 @@ Unlike `set: null`, `unset` removes the list entirely.
## Adding items to a scalar list
-
+:::warning
Available for:
@@ -91,7 +91,7 @@ Available for:
- CockroachDB in versions [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) and later
- MongoDB in versions [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0) and later
-
+:::
Use the [`push`](/orm/reference/prisma-client-reference#push) method to add a single value to a scalar list:
@@ -137,7 +137,7 @@ if (user) {
## Filtering scalar lists
-
+:::warning
Available for:
@@ -145,7 +145,7 @@ Available for:
- CockroachDB in versions [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) and later
- MongoDB in versions [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0) and later
-
+:::
Use [scalar list filters](/orm/reference/prisma-client-reference#scalar-list-filters) to filter for records with scalar lists that match a specific condition. The following example returns all posts where the tags list includes `databases` _and_ `typescript`:
@@ -161,14 +161,14 @@ const posts = await prisma.post.findMany({
### `NULL` values in arrays
-
+:::warning
This section applies to:
- PostgreSQL in versions [2.15.0](https://github.com/prisma/prisma/releases/tag/2.15.0) and later
- CockroachDB in versions [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) and later
-
+:::
When using scalar list filters with a relational database connector, array fields with a `NULL` value are not considered by the following conditions:
diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/300-working-with-composite-ids-and-constraints.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/300-working-with-composite-ids-and-constraints.mdx
index d687f60a12..568682f30a 100644
--- a/content/200-orm/200-prisma-client/200-special-fields-and-types/300-working-with-composite-ids-and-constraints.mdx
+++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/300-working-with-composite-ids-and-constraints.mdx
@@ -9,12 +9,12 @@ tocDepth: 2
Composite IDs and compound unique constraints can be defined in your Prisma schema using the [`@@id`](/orm/reference/prisma-schema-reference#id-1) and [`@@unique`](/orm/reference/prisma-schema-reference#unique-1) attributes.
-
+:::warning
**MongoDB does not support `@@id`**
MongoDB does not support composite IDs, which means you cannot identify a model with a `@@id` attribute.
-
+:::
A composite ID or compound unique constraint uses the combined values of two fields as a primary key or identifier in your database table. In the following example, the `postId` field and `userId` field are used as a composite ID for a `Like` table:
@@ -101,11 +101,11 @@ const like = await prisma.like.findUnique({
})
```
-
+:::info
Note composite ID and compound unique constraint keys are only available as filter options for _unique_ queries such as `findUnique()` and `findUniqueOrThrow`. See the [section](/orm/prisma-client/special-fields-and-types/working-with-composite-ids-and-constraints#where-you-can-use-compound-ids-and-unique-constraints) above for a list of places these fields may be used.
-
+:::
## Deleting records by a compound ID or unique constraint
diff --git a/content/200-orm/200-prisma-client/300-client-extensions/100-model.mdx b/content/200-orm/200-prisma-client/300-client-extensions/100-model.mdx
index d293617e46..4af89011b1 100644
--- a/content/200-orm/200-prisma-client/300-client-extensions/100-model.mdx
+++ b/content/200-orm/200-prisma-client/300-client-extensions/100-model.mdx
@@ -7,11 +7,11 @@ toc_max_heading_level: 4
-
+:::info
Prisma Client extensions are Generally Available from versions 4.16.0 and later. They were introduced in Preview in version 4.7.0. Make sure you enable the `clientExtensions` Preview feature flag if you are running on a version earlier than 4.16.0.
-
+:::
You can use the `model` [Prisma Client extensions](/orm/prisma-client/client-extensions) component type to add custom methods to your models.
@@ -134,11 +134,11 @@ const prisma = new PrismaClient().$extends({
## Get the current model name at runtime
-
+:::info
This feature is available from version 4.9.0.
-
+:::
You can get the name of the current model at runtime with `Prisma.getExtensionContext(this).$name`. You might use this to write out the model name to a log, to send the name to another service, or to branch your code based on the model.
diff --git a/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx b/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx
index 5aad99108e..5b1672e143 100644
--- a/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx
+++ b/content/200-orm/200-prisma-client/300-client-extensions/110-client.mdx
@@ -7,11 +7,11 @@ toc_max_heading_level: 4
-
+:::info
Prisma Client extensions are Generally Available from versions 4.16.0 and later. They were introduced in Preview in version 4.7.0. Make sure you enable the `clientExtensions` Preview feature flag if you are running on a version earlier than 4.16.0.
-
+:::
You can use the `client` [Prisma Client extensions](/orm/prisma-client/client-extensions) component to add top-level methods to Prisma Client.
@@ -36,11 +36,11 @@ The following example uses the `client` component to add two methods to Prisma C
- `$log` outputs a message.
- `$totalQueries` returns the number of queries executed by the current client instance. It uses the [metrics](/orm/prisma-client/observability-and-logging/metrics) feature to collect this information.
-
+:::info
To use metrics in your project, you must enable the `metrics` feature flag in the `generator` block of your `schema.prisma` file. [Learn more](/orm/prisma-client/observability-and-logging/metrics#2-enable-the-feature-flag-in-the-prisma-schema-file).
-
+:::
```ts
const prisma = new PrismaClient().$extends({
diff --git a/content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx b/content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx
index 9c408e7620..26bb67e1b4 100644
--- a/content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx
+++ b/content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx
@@ -7,11 +7,11 @@ toc_max_heading_level: 4
-
+:::info
Prisma Client extensions are Generally Available from versions 4.16.0 and later. They were introduced in Preview in version 4.7.0. Make sure you enable the `clientExtensions` Preview feature flag if you are running on a version earlier than 4.16.0.
-
+:::
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.
@@ -254,11 +254,11 @@ const prisma = new PrismaClient().$extends({
})
```
-
+:::info
We include the above example to show that this is possible. However, for performance reasons we recommend that you use the [`result` component type](/orm/prisma-client/client-extensions/result) to override existing fields. The `result` component type usually gives better performance in this situation because it computes only on access. The `query` component type computes after query execution.
-
+:::
## Wrap a query into a batch transaction
diff --git a/content/200-orm/200-prisma-client/300-client-extensions/130-result.mdx b/content/200-orm/200-prisma-client/300-client-extensions/130-result.mdx
index a413790ec3..66eedda8c7 100644
--- a/content/200-orm/200-prisma-client/300-client-extensions/130-result.mdx
+++ b/content/200-orm/200-prisma-client/300-client-extensions/130-result.mdx
@@ -7,11 +7,11 @@ toc_max_heading_level: 4
-
+:::info
Prisma Client extensions are Generally Available from versions 4.16.0 and later. They were introduced in Preview in version 4.7.0. Make sure you enable the `clientExtensions` Preview feature flag if you are running on a version earlier than 4.16.0.
-
+:::
You can use the `result` [Prisma Client extensions](/orm/prisma-client/client-extensions) component type to add custom fields and methods to query results.
diff --git a/content/200-orm/200-prisma-client/300-client-extensions/index.mdx b/content/200-orm/200-prisma-client/300-client-extensions/index.mdx
index d0bb657074..50e60c8a44 100644
--- a/content/200-orm/200-prisma-client/300-client-extensions/index.mdx
+++ b/content/200-orm/200-prisma-client/300-client-extensions/index.mdx
@@ -7,11 +7,11 @@ toc_max_heading_level: 4
-
+:::info
Prisma Client extensions are Generally Available from versions 4.16.0 and later. They were introduced in Preview in version 4.7.0. Make sure you enable the `clientExtensions` Preview feature flag if you are running on a version earlier than 4.16.0.
-
+:::
You can use Prisma Client extensions to add functionality to your models, result objects, and queries, or to add client-level methods.
diff --git a/content/200-orm/200-prisma-client/400-type-safety/830-prisma-type-system.mdx b/content/200-orm/200-prisma-client/400-type-safety/830-prisma-type-system.mdx
index 17a6241106..b7d4854e2b 100644
--- a/content/200-orm/200-prisma-client/400-type-safety/830-prisma-type-system.mdx
+++ b/content/200-orm/200-prisma-client/400-type-safety/830-prisma-type-system.mdx
@@ -17,7 +17,6 @@ Prisma ORM uses _types_ to define the kind of data that a field can hold. To mak
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model Post {
diff --git a/content/200-orm/200-prisma-client/400-type-safety/index.mdx b/content/200-orm/200-prisma-client/400-type-safety/index.mdx
index caa214ec6e..9271036924 100644
--- a/content/200-orm/200-prisma-client/400-type-safety/index.mdx
+++ b/content/200-orm/200-prisma-client/400-type-safety/index.mdx
@@ -233,11 +233,11 @@ We recommend using the "safe" `Input` types whenever possible.
## Type utilities
-
+:::info
This feature is available from Prisma ORM version 4.9.0 upwards.
-
+:::
To help you create highly type-safe applications, Prisma Client provides a set of type utilities that tap into input and output types. These types are fully dynamic, which means that they adapt to any given model and schema. You can use them to improve the auto-completion and developer experience of your projects.
diff --git a/content/200-orm/200-prisma-client/450-testing/100-unit-testing.mdx b/content/200-orm/200-prisma-client/450-testing/100-unit-testing.mdx
index 931d78b14c..1d8e5060bf 100644
--- a/content/200-orm/200-prisma-client/450-testing/100-unit-testing.mdx
+++ b/content/200-orm/200-prisma-client/450-testing/100-unit-testing.mdx
@@ -37,11 +37,11 @@ This guide will cover two approaches to mocking Prisma Client, a singleton insta
npm install jest-mock-extended@2.0.4 --save-dev
```
-
+:::danger
At the time of writing, this guide uses `jest-mock-extended` version `^2.0.4`.
-
+:::
### Singleton
diff --git a/content/200-orm/200-prisma-client/450-testing/150-integration-testing.mdx b/content/200-orm/200-prisma-client/450-testing/150-integration-testing.mdx
index 25dcff2e82..de0d154efe 100644
--- a/content/200-orm/200-prisma-client/450-testing/150-integration-testing.mdx
+++ b/content/200-orm/200-prisma-client/450-testing/150-integration-testing.mdx
@@ -122,11 +122,11 @@ The `docker-compose.yml` file defines the following:
DATABASE_URL="postgresql://prisma:prisma@localhost:5433/tests"
```
-
+:::info
The above `.env.test` file is used as part of a multiple `.env` file setup. Checkout the [using multiple .env files.](/orm/more/development-environment/environment-variables) section to learn more about setting up your project with multiple `.env` files
-
+:::
3. To create the container in a detached state so that you can continue to use the terminal tab, run the following command:
diff --git a/content/200-orm/200-prisma-client/500-deployment/201-serverless/300-deploy-to-vercel.mdx b/content/200-orm/200-prisma-client/500-deployment/201-serverless/300-deploy-to-vercel.mdx
index f5717fed5f..baedae6a6b 100644
--- a/content/200-orm/200-prisma-client/500-deployment/201-serverless/300-deploy-to-vercel.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/201-serverless/300-deploy-to-vercel.mdx
@@ -148,7 +148,7 @@ Use `attachDatabasePool` together with [Prisma's driver adapters](/orm/overview/
import { Pool } from 'pg'
import { attachDatabasePool } from '@vercel/functions'
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
const pool = new Pool({ connectionString: process.env.POSTGRES_URL })
diff --git a/content/200-orm/200-prisma-client/500-deployment/201-serverless/400-deploy-to-aws-lambda.mdx b/content/200-orm/200-prisma-client/500-deployment/201-serverless/400-deploy-to-aws-lambda.mdx
index fc386c5aa4..0d17dffc3a 100644
--- a/content/200-orm/200-prisma-client/500-deployment/201-serverless/400-deploy-to-aws-lambda.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/201-serverless/400-deploy-to-aws-lambda.mdx
@@ -357,7 +357,7 @@ While SST supports `.env` files, [it is not recommended](https://v2.sst.dev/conf
The SST guide [available here](https://v2.sst.dev/config#overview) is a step-by-step guide to get started with `Config`. Assuming you have created a new secret called `DATABASE_URL` and have [bound that secret to your app](https://v2.sst.dev/config#bind-the-config), you can set up `PrismaClient` with the following:
```ts file=prisma.ts showLineNumbers
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { Config } from 'sst/node/config'
const globalForPrisma = global as unknown as { prisma: PrismaClient }
diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx
index c12f9ddf1e..9ebbb0b4ac 100644
--- a/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx
@@ -73,7 +73,7 @@ npm i @prisma/extension-accelerate
And extend `PrismaClient` with the extension in your application code:
```typescript
-import { PrismaClient } from "@prisma/client/edge";
+import { PrismaClient } from "./generated/client";
import { withAccelerate } from "@prisma/extension-accelerate";
export interface Env {
@@ -123,15 +123,26 @@ If your application uses PostgreSQL, we recommend using [Prisma Postgres](/postg
### Setting your database connection URL as an environment variable
-First, ensure that the `DATABASE_URL` is set as the `url` of the `datasource` in your Prisma schema:
+First, ensure that your `datasource` block in your Prisma schema is configured correctly. Database connection URLs are configured in `prisma.config.ts`:
```prisma
datasource db {
provider = "postgresql" // this might also be `mysql` or another value depending on your database
- url = env("DATABASE_URL")
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
#### Development
When using your Worker in **development**, you can configure your database connection via the [`.dev.vars` file](https://developers.cloudflare.com/workers/configuration/secrets/#local-development-with-secrets) locally.
@@ -253,19 +264,31 @@ If you don't have a project to deploy, follow the instructions in the [Prerequis
:::
-First, ensure that the database connection is configured properly. In your Prisma schema, set the `url` of the `datasource` block to the `DATABASE_URL` environment variable:
+First, ensure that the database connection is configured properly. Database connection URLs are configured in `prisma.config.ts`:
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
Next, you need to set the `DATABASE_URL` environment variable to the value of your database connection string. You'll do this in a file called `.dev.vars` used by Cloudflare:
```bash file=.dev.vars
@@ -328,7 +351,7 @@ npm run env -- npx prisma migrate dev --name init
Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaPg } from '@prisma/adapter-pg'
export default {
@@ -412,16 +435,28 @@ First, ensure that the database connection is configured properly. In your Prism
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
relationMode = "prisma" // required for PlanetScale (as by default foreign keys are disabled)
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
Next, you need to set the `DATABASE_URL` environment variable to the value of your database connection string. You'll do this in a file called `.dev.vars` used by Cloudflare:
```bash file=.dev.vars
@@ -470,7 +505,7 @@ npm run env -- npx prisma db push
Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
export default {
@@ -538,19 +573,31 @@ If you don't have a project to deploy, follow the instructions in the [Prerequis
:::
-First, ensure that the database connection is configured properly. In your Prisma schema, set the `url` of the `datasource` block to the `DATABASE_URL` environment variable:
+First, ensure that the database connection is configured properly. Database connection URLs are configured in `prisma.config.ts`:
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
Next, you need to set the `DATABASE_URL` environment variable to the value of your database connection string. You'll do this in a file called `.dev.vars` used by Cloudflare:
```bash file=.dev.vars
@@ -599,7 +646,7 @@ npm run env -- npx prisma migrate dev --name init
Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database:
```ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaNeon } from '@prisma/adapter-neon'
export default {
diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx
index bab4e03d21..f5d06377d7 100644
--- a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx
@@ -87,15 +87,26 @@ If your application uses PostgreSQL, we recommend using [Prisma Postgres](/postg
### Setting your database connection URL as an environment variable
-First, ensure that the `DATABASE_URL` is set as the `url` of the `datasource` in your Prisma schema:
+First, ensure that your `datasource` block in your Prisma schema is configured correctly. Database connection URLs are configured in `prisma.config.ts`:
```prisma
datasource db {
provider = "postgresql" // this might also be `mysql` or another value depending on your database
- url = env("DATABASE_URL")
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
#### Development
When in **development**, you can configure your database connection via the `DATABASE_URL` environment variable (e.g. [using `.env` files](/orm/more/development-environment/environment-variables)).
@@ -159,13 +170,17 @@ model User {
If you are using Vercel Postgres, you need to:
- use the `@prisma/adapter-neon` database adapter because Vercel Postgres uses [Neon](https://neon.tech/) under the hood
-- be aware that Vercel by default calls the environment variable for the database connection string `POSTGRES_PRISMA_URL` while the default name used in the Prisma docs is typically `DATABASE_URL`; using Vercel's naming, you need to set the following fields on your `datasource` block:
- ```prisma
- datasource db {
- provider = "postgresql"
- url = env("POSTGRES_PRISMA_URL") // uses connection pooling
- directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
- }
+- be aware that Vercel by default calls the environment variable for the database connection string `POSTGRES_PRISMA_URL` while the default name used in the Prisma docs is typically `DATABASE_URL`; using Vercel's naming, you need to configure these in `prisma.config.ts`:
+ ```ts file=prisma.config.ts
+ import { defineConfig, env } from 'prisma/config'
+
+ export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('POSTGRES_PRISMA_URL'), // uses connection pooling
+ directUrl: env('POSTGRES_URL_NON_POOLING'), // uses a direct connection
+ },
+ })
```
#### 1. Configure Prisma schema & database connection
@@ -176,20 +191,32 @@ If you don't have a project to deploy, follow the instructions in the [Prerequis
:::
-First, ensure that the database connection is configured properly. In your Prisma schema, set the `url` of the `datasource` block to the `POSTGRES_PRISMA_URL` and the `directUrl` to the `POSTGRES_URL_NON_POOLING` environment variable:
+First, ensure that the database connection is configured properly. Database connection URLs are configured in `prisma.config.ts`:
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
- provider = "postgresql"
- url = env("POSTGRES_PRISMA_URL") // uses connection pooling
- directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
+ provider = "postgresql"
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('POSTGRES_PRISMA_URL'), // uses connection pooling
+ directUrl: env('POSTGRES_URL_NON_POOLING'), // uses a direct connection
+ },
+})
+```
+
Next, you need to set the `POSTGRES_PRISMA_URL` and `POSTGRES_URL_NON_POOLING` environment variable to the values of your database connection.
If you ran `npx prisma init`, you can use the `.env` file that was created by this command to set these:
@@ -246,7 +273,7 @@ Here is a sample code snippet that you can use to instantiate `PrismaClient` and
```ts file=app/api/edge/route.ts showLineNumbers
import { NextResponse } from 'next/server'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaNeon } from '@prisma/adapter-neon'
export const runtime = 'nodejs' // can also be set to 'edge'
@@ -301,20 +328,32 @@ If you don't have a project to deploy, follow the instructions in the [Prerequis
:::
-First, ensure that the database connection is configured properly. In your Prisma schema, set the `url` of the `datasource` block to the `DATABASE_URL` environment variable:
+First, ensure that the database connection is configured properly. Database connection URLs are configured in `prisma.config.ts`:
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
relationMode = "prisma" // required for PlanetScale (as by default foreign keys are disabled)
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
Next, you need to set the `DATABASE_URL` environment variable in your `.env` file that's used both by Prisma and Next.js to read your env vars:
```bash file=.env
@@ -368,7 +407,7 @@ Here is a sample code snippet that you can use to instantiate `PrismaClient` and
```ts file=app/api/edge/route.ts showLineNumbers
import { NextResponse } from 'next/server'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
export const runtime = 'nodejs' // can also be set to 'edge'
@@ -423,19 +462,31 @@ If you don't have a project to deploy, follow the instructions in the [Prerequis
:::
-First, ensure that the database connection is configured properly. In your Prisma schema, set the `url` of the `datasource` block to the `DATABASE_URL` environment variable:
+First, ensure that the database connection is configured properly. Database connection URLs are configured in `prisma.config.ts`:
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
+```ts file=prisma.config.ts
+import 'dotenv/config'
+import { defineConfig, env } from 'prisma/config'
+
+export default defineConfig({
+ schema: 'prisma/schema.prisma',
+ datasource: {
+ url: env('DATABASE_URL'),
+ },
+})
+```
+
Next, you need to set the `DATABASE_URL` environment variable in your `.env` file that's used both by Prisma and Next.js to read your env vars:
```bash file=.env showLineNumbers
@@ -489,7 +540,7 @@ Here is a sample code snippet that you can use to instantiate `PrismaClient` and
```ts file=app/api/edge/route.ts showLineNumbers
import { NextResponse } from 'next/server'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
import { PrismaNeon } from '@prisma/adapter-neon'
export const runtime = 'nodejs' // can also be set to 'edge'
@@ -540,7 +591,7 @@ Use `attachDatabasePool` together with [Prisma's driver adapters](/orm/overview/
import { Pool } from 'pg'
import { attachDatabasePool } from '@vercel/functions'
import { PrismaPg } from '@prisma/adapter-pg'
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from './generated/client'
const pool = new Pool({ connectionString: process.env.POSTGRES_URL })
diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
index 24c7af9c08..88c15dfb4c 100644
--- a/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/550-deploy-to-deno-deploy.mdx
@@ -10,12 +10,6 @@ With this guide, you can learn how to build and deploy a simple application to [
This guide covers the use of Prisma CLI with Deno CLI, Deno Deploy, Prisma Client, and Prisma Postgres.
-:::info
-
-This guide demonstrates how to deploy an application to Deno Deploy with a Prisma Postgres database, but you can also use [your own database with Prisma Accelerate](/accelerate/getting-started#prerequisites).
-
-:::
-
:::tip Use Prisma ORM without Rust binaries
If Prisma ORM's Rust engine binaries cause large bundle sizes, slow builds, or deployment issues (for example, in serverless or edge environments), you can use it without them using this configuration of your `generator` block:
@@ -70,7 +64,7 @@ This command:
- Connects your CLI to your [Prisma Data Platform](https://console.prisma.io) account. If you're not logged in or don't have an account, your browser will open to guide you through creating a new account or signing into your existing one.
- Creates a `prisma` directory containing a `schema.prisma` file for your database models.
-- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`).
+- Creates a `.env` file with your `DATABASE_URL` (e.g., `DATABASE_URL="postgresql://user:password@host:5432/database"`).
Edit the `prisma/schema.prisma` file to define a `Log` model, add a custom `output` path and [the `prisma-client` generator](/orm/prisma-schema/overview/generators#prisma-client) with `deno` as the `runtime`:
@@ -88,7 +82,6 @@ generator client {
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
//add-start
@@ -107,16 +100,11 @@ enum Level {
//add-end
```
-Then, install Prisma Client:
+Then, install Prisma Client and the Postgres adapter:
```terminal
deno install npm:@prisma/client
-```
-
-Then, install [the Client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) required to use Prisma Postgres:
-
-```terminal
-deno install npm:@prisma/extension-accelerate
+deno install npm:@prisma/adapter-pg
```
Prisma Client does not read `.env` files by default on Deno, so you must also install `dotenv-cli` locally:
@@ -146,10 +134,12 @@ You can now create a local Deno application. Create `index.ts` in the root folde
```ts file=index.ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
-import { withAccelerate } from "npm:@prisma/extension-accelerate";
-import { PrismaClient } from "./generated/prisma/client.ts";
+import { PrismaPg } from "npm:@prisma/adapter-pg";
+import { PrismaClient } from "../generated/prisma/client.ts";
-const prisma = new PrismaClient().$extends(withAccelerate());
+const connectionString = `${Deno.env.get("DATABASE_URL")}`;
+const adapter = new PrismaPg({ connectionString });
+const prisma = new PrismaClient({ adapter });
async function handler(request: Request) {
// Ignore /favicon.ico requests:
@@ -253,10 +243,12 @@ Add the following code in your `index.ts` file:
```ts file=index.ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
-import { withAccelerate } from "npm:@prisma/extension-accelerate";
-import { PrismaClient } from "./generated/prisma/client.ts";
+import { PrismaPg } from "npm:@prisma/adapter-pg";
+import { PrismaClient } from "../generated/prisma/client.ts";
-const prisma = new PrismaClient().$extends(withAccelerate());
+const connectionString = `${Deno.env.get("DATABASE_URL")}`;
+const adapter = new PrismaPg({ connectionString });
+const prisma = new PrismaClient({ adapter });
async function handler(request: Request) {
// Ignore /favicon.ico requests:
@@ -310,4 +302,4 @@ This rebuilds the deployment, which now works because the environment variable h
## Summary
-You successfully deployed a Deno application that you created in TypeScript, which uses Prisma Client connecting to a Prisma Postgres database.
+You successfully deployed a Deno application that you created in TypeScript, which uses Prisma Client with the Postgres adapter to connect to a Postgres database.
diff --git a/content/200-orm/200-prisma-client/500-deployment/550-deploy-database-changes-with-prisma-migrate.mdx b/content/200-orm/200-prisma-client/500-deployment/550-deploy-database-changes-with-prisma-migrate.mdx
index 7cae20ec3e..d3ddf28ec3 100644
--- a/content/200-orm/200-prisma-client/500-deployment/550-deploy-database-changes-with-prisma-migrate.mdx
+++ b/content/200-orm/200-prisma-client/500-deployment/550-deploy-database-changes-with-prisma-migrate.mdx
@@ -12,12 +12,12 @@ To apply pending migrations to staging, testing, or production environments, run
npx prisma migrate deploy
```
-
+:::info
This guide **does not apply for MongoDB**.
Instead of `migrate deploy`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
Exactly when to run `prisma migrate deploy` depends on your platform. For example, a simplified [Heroku](/orm/prisma-client/deployment/traditional/deploy-to-heroku) workflow includes:
diff --git a/content/200-orm/200-prisma-client/600-observability-and-logging/130-logging.mdx b/content/200-orm/200-prisma-client/600-observability-and-logging/130-logging.mdx
index a0c46bb2d7..8466e68656 100644
--- a/content/200-orm/200-prisma-client/600-observability-and-logging/130-logging.mdx
+++ b/content/200-orm/200-prisma-client/600-observability-and-logging/130-logging.mdx
@@ -13,17 +13,17 @@ Prisma Client supports two types of logging:
- Logging to [stdout](https://en.wikipedia.org/wiki/Standard_streams) (default)
- Event-based logging (use [`$on()`](/orm/reference/prisma-client-reference#on) method to [subscribe to events](#event-based-logging))
-
+:::info
You can also use the `DEBUG` environment variable to enable debugging output in Prisma Client. See [Debugging](/orm/prisma-client/debugging-and-troubleshooting/debugging) for more information.
-
+:::
-
+:::info
If you want a detailed insight into your Prisma Client's performance at the level of individual operations, see [Tracing](/orm/prisma-client/observability-and-logging/opentelemetry-tracing).
-
+:::
diff --git a/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx b/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx
index cff5a46155..65b0680781 100644
--- a/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx
+++ b/content/200-orm/200-prisma-client/600-observability-and-logging/240-metrics.mdx
@@ -98,7 +98,8 @@ In the `generator` block of your `schema.prisma` file, enable the `metrics` feat
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["metrics"]
}
```
@@ -297,12 +298,12 @@ Each histogram "bucket" has two values. The first one is the upper bound of the
You can send JSON-formatted metrics to [StatsD](https://github.com/statsd/statsd) to visualize your metrics data over time.
-
+:::info
Note: You must provide counter metrics to StatsD as a series of values that are incremented or decremented from a previous retrieval of the metrics. However, Prisma Client's counter
metrics return absolute values. Therefore, you must convert your counter metrics to a series of incremented and decremented values and send them to StatsD as gauge data. In the code example below, we convert counter metrics into incremented and decremented gauge data in `diffHistograms`.
-
+:::
In the following example, we send metrics to StatsD every 10 seconds. This timing aligns with the default 10s flush rate of StatsD.
@@ -512,7 +513,7 @@ For more information, read the Prometheus documentation on [metric types](https:
In the majority of cases, Prometheus must scrape an endpoint to retrieve metrics. The following example shows how to send data with `Express.js`:
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import express, { Request, Response } from 'express'
const app = express()
@@ -532,7 +533,7 @@ app.listen(port, () => {
The following example shows how to combine Prisma Client metrics with other Prometheus client libraries that are also served with a REST API endpoint in conjunction with `Express.js`:
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import express, { Request, Response } from 'express'
import prom from 'prom-client'
diff --git a/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx b/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx
index f1b866c7d3..c3803e14ad 100644
--- a/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx
+++ b/content/200-orm/200-prisma-client/600-observability-and-logging/250-opentelemetry-tracing.mdx
@@ -96,7 +96,8 @@ Tracing was added in version `4.2.0` of Prisma ORM as a Preview feature. For ver
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["tracing"]
}
```
@@ -295,12 +296,12 @@ As an example, take the following Prisma schema:
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
@@ -468,7 +469,7 @@ registerTracing({
})
// You must import any dependencies after you register tracing.
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import async from 'express-async-handler'
import express from 'express'
```
diff --git a/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/245-troubleshooting-binary-size-issues.mdx b/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/245-troubleshooting-binary-size-issues.mdx
index 01ecf50d9b..9d65481b98 100644
--- a/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/245-troubleshooting-binary-size-issues.mdx
+++ b/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/245-troubleshooting-binary-size-issues.mdx
@@ -11,7 +11,8 @@ As of [v6.16.0](https://pris.ly/release/6.16.0), you can resolve these issues by
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
engineType = "client"
}
````
diff --git a/content/200-orm/300-prisma-migrate/050-getting-started.mdx b/content/200-orm/300-prisma-migrate/050-getting-started.mdx
index 20aa70d447..48f5ac3122 100644
--- a/content/200-orm/300-prisma-migrate/050-getting-started.mdx
+++ b/content/200-orm/300-prisma-migrate/050-getting-started.mdx
@@ -17,7 +17,6 @@ To get started with Prisma Migrate in a development environment:
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
diff --git a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/005-overview.mdx b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/005-overview.mdx
index f458f09c12..8fba5dfbf8 100644
--- a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/005-overview.mdx
+++ b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/005-overview.mdx
@@ -9,11 +9,11 @@ hide_table_of_contents: true
-
+:::info
**Does not apply for MongoDB**
Instead of `migrate dev` and related commands, use [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
Prisma Migrate enables you to:
diff --git a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/200-shadow-database.mdx b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/200-shadow-database.mdx
index bfcec4db00..765ed01f61 100644
--- a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/200-shadow-database.mdx
+++ b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/200-shadow-database.mdx
@@ -13,17 +13,17 @@ The shadow database is a second, _temporary_ database that is **created and dele
* If your database does not allow creation and deleting of databases (e.g. in a cloud-hosted environment), you need to [create and configure the shadow database manually](#cloud-hosted-shadow-databases-must-be-created-manually).
-
+:::warning
The shadow database is **not** required in production, and is not used by production-focused commands such as `prisma migrate resolve` and `prisma migrate deploy`.
-
+:::
-
+:::note
A shadow database is never used for MongoDB as `migrate dev` is not used there.
-
+:::
@@ -86,7 +86,6 @@ In some cases it might make sense (e.g. when [creating and dropping databases is
```prisma highlight=4;normal
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//highlight-next-line
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
@@ -105,7 +104,6 @@ Some cloud providers do not allow you to drop and create databases with SQL. Som
```prisma highlight=4;normal
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//highlight-next-line
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/10-seeding.mdx b/content/200-orm/300-prisma-migrate/300-workflows/10-seeding.mdx
index baf2358905..0b186e2444 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/10-seeding.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/10-seeding.mdx
@@ -27,7 +27,7 @@ Prisma ORM's integrated seeding functionality expects a command in the `"seed"`
```
-
+:::info
With TypeScript,`ts-node` does transpiling and typechecking by default; typechecking can be disabled with the following flag `--transpile-only`.
@@ -36,7 +36,7 @@ Example:
This can be useful to reduce memory usage (RAM) and increase execution speed of the seed script.
-
+:::
@@ -100,7 +100,7 @@ Here we suggest some specific seed scripts for different situations. You are fre
Create some new users and posts in your `seed.ts` file:
```js file=seed.ts
- import { PrismaClient } from '@prisma/client'
+ import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
async function main() {
const alice = await prisma.user.upsert({
@@ -198,12 +198,12 @@ Here we suggest some specific seed scripts for different situations. You are fre
2. In the `seed.js` file, import Prisma Client, initialize it and create some records. As an example, take the following Prisma schema with a `User` and `Post` model:
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/110-native-database-types.mdx b/content/200-orm/300-prisma-migrate/300-workflows/110-native-database-types.mdx
index ba21b41f1f..81357ea4b3 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/110-native-database-types.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/110-native-database-types.mdx
@@ -32,18 +32,17 @@ Comments and Prisma ORM-level functions (`uuid()` and `cuid()`) do not map to da
Each Prisma ORM type maps to a default underlying database type - for example, the PostgreSQL connector maps `String` to `text` by default. [Native database type attributes](/orm/prisma-schema/data-model/models#native-types-mapping) determines which _specific_ native type should be created in the database.
-
+:::info
-**Note**: Some Prisma ORM types only map to a single native type.
+Some Prisma ORM types only map to a single native type.
-
+:::
In the following example, the `name` and `title` fields have a `@db.VarChar(X)` type attribute:
```prisma highlight=8,14;normal
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/120-native-database-functions.mdx b/content/200-orm/300-prisma-migrate/300-workflows/120-native-database-functions.mdx
index 42cde2be6e..511016c829 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/120-native-database-functions.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/120-native-database-functions.mdx
@@ -10,24 +10,24 @@ In PostgreSQL, some [native database functions](/orm/prisma-schema/data-model/un
To use a PostgreSQL extension, you must install it on the file system of your database server and then activate the extension. If you use Prisma Migrate, this must be done as part of a migration.
-
+:::warning
Do not activate extensions outside a migration file if you use Prisma Migrate. The [shadow database](/orm/prisma-migrate/understanding-prisma-migrate/shadow-database) requires the same extensions. Prisma Migrate creates and deletes the shadow database automatically, so the only way to activate an extension is to include it in a migration file.
-
+:::
In Prisma ORM versions 4.5.0 and later, you can activate the extension by declaring it in your Prisma schema with the [`postgresqlExtensions` preview feature](/orm/prisma-schema/postgresql-extensions):
```prisma file=schema.prisma highlight=3,9;add showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
//add-next-line
previewFeatures = ["postgresqlExtensions"]
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//add-next-line
extensions = [pgcrypto]
}
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/20-prototyping-your-schema.mdx b/content/200-orm/300-prisma-migrate/300-workflows/20-prototyping-your-schema.mdx
index e019dc32a6..1ffac88301 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/20-prototyping-your-schema.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/20-prototyping-your-schema.mdx
@@ -53,12 +53,12 @@ The following scenario demonstrates how to use `db push` to synchronize a new sc
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
@@ -176,12 +176,12 @@ The following scenario demonstrates how to use `db push` to prototype a change t
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/200-troubleshooting.mdx b/content/200-orm/300-prisma-migrate/300-workflows/200-troubleshooting.mdx
index 01d04f10c9..90014f2d77 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/200-troubleshooting.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/200-troubleshooting.mdx
@@ -11,12 +11,12 @@ This guide describes how to resolve issues with Prisma Migrate in a development
- [Production troubleshooting](/orm/prisma-migrate/workflows/patching-and-hotfixing)
- [Patching / hotfixing production databases](/orm/prisma-migrate/workflows/patching-and-hotfixing)
-
+:::warning
This guide **does not apply for MongoDB**.
Instead of `migrate dev`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/30-baselining.mdx b/content/200-orm/300-prisma-migrate/300-workflows/30-baselining.mdx
index 930c3afdb1..caec87136d 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/30-baselining.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/30-baselining.mdx
@@ -16,12 +16,12 @@ Baselining tells Prisma Migrate to assume that one or more migrations have **alr
Baselining is part of [adding Prisma Migrate to a project with an existing database](/orm/prisma-migrate/getting-started#adding-prisma-migrate-to-an-existing-project).
-
+:::warning
This guide **does not apply for MongoDB**.
Instead of `migrate deploy`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/40-customizing-migrations.mdx b/content/200-orm/300-prisma-migrate/300-workflows/40-customizing-migrations.mdx
index e96f27e88c..d41ee7ba19 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/40-customizing-migrations.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/40-customizing-migrations.mdx
@@ -7,12 +7,12 @@ tocDepth: 3
-
+:::warning
This guide **does not apply for MongoDB**.
Instead of `migrate dev`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
In some scenarios, you need to edit a migration file before you apply it. For example, to [change the direction of a 1-1 relation](#example-change-the-direction-of-a-1-1-relation) (moving the foreign key from one side to another) without data loss, you need to move data as part of the migration - this SQL is not part of the default migration, and must be written by hand.
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/50-squashing-migrations.mdx b/content/200-orm/300-prisma-migrate/300-workflows/50-squashing-migrations.mdx
index 8faac3bf46..2b594c4753 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/50-squashing-migrations.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/50-squashing-migrations.mdx
@@ -36,11 +36,11 @@ For detailed steps on how to achieve this using `migrate diff` and `migrate reso
## Considerations when squashing migrations
-
+:::warning
When squashing migrations, be aware that any manually changed or added SQL in your `migration.sql` files will not be retained. If you have migration files with custom additions such as a view or a trigger, ensure to re-add them after your migrations were squashed.
-
+:::
## How to squash migrations
@@ -57,11 +57,11 @@ Before squashing your migrations, make sure you have the following starting cond
- All migrations applied to production are part of the local migration history already
- There is no custom SQL in any of the new migration files that you have added to your branch
-
+:::info
If the migration history on the production database has diverged after you created your feature branch, then you would need to first merge the migrations history and the datamodel changes from production into your local history.
-
+:::
Then follow these steps:
@@ -95,11 +95,11 @@ Then follow these steps, either on your `main` branch or on a newly checked out
2. Create a new empty directory in the `./prisma/migrations` directory. In this guide this will be called `000000000000_squashed_migrations`. Inside this, add a new empty `migration.sql` file.
-
+ :::info
We name the migration `000000000000_squashed_migrations` with all the leading zeroes because we want it to be the first migration in the migrations directory. Migrate runs the migrations in the directory in lexicographic (alphabetical) order. This is why it generates migrations with the date and time as a prefix when you use `migrate dev`. You can give the migration another name, as long as it it sorts lower than later migrations, for example `0_squashed` or `202207180000_squashed`.
-
+ :::
3. Create a single migration that takes you:
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/60-generating-down-migrations.mdx b/content/200-orm/300-prisma-migrate/300-workflows/60-generating-down-migrations.mdx
index 5f20a17429..bc3e5af495 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/60-generating-down-migrations.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/60-generating-down-migrations.mdx
@@ -17,17 +17,17 @@ When generating a migration SQL file, you may wish to also create a "down migrat
This guide explains how to use Prisma Migrate's [`migrate diff` command](/orm/reference/prisma-cli-reference#migrate-diff) to create a down migration, and how to apply it to your production database with the [`db execute`](/orm/reference/prisma-cli-reference#db-execute) command in the case of a failed up migration.
-
+:::warning
This guide applies to generating SQL down migrations for relational databases only. It does not apply to MongoDB.
-
+:::
-
+:::info
The `migrate diff` and `db execute` commands are available in Preview in versions `3.9.0` and later, and are generally available in versions `3.13.0` and later.
-
+:::
## Considerations when generating down migrations
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/70-patching-and-hotfixing.mdx b/content/200-orm/300-prisma-migrate/300-workflows/70-patching-and-hotfixing.mdx
index c9a2e6fc68..d17cc95bbd 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/70-patching-and-hotfixing.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/70-patching-and-hotfixing.mdx
@@ -9,12 +9,12 @@ Patching or hotfixing a database involves making an often time critical change d
Patching the production database directly results in **schema drift**: your database schema has 'drifted away' from the source of truth, and is out of sync with your migration history. You can use the `prisma migrate resolve` command to reconcile your migration history _without_ having to remove and re-apply the hotfix with `prisma migrate deploy`.
-
+:::warning
This guide **does not apply for MongoDB**.
Instead of `migrate dev`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
@@ -252,11 +252,11 @@ Your local migration history now yields the same result as the state your produc
## Migration history conflicts
-
+:::info
This does not apply from version [3.12.0](https://github.com/prisma/prisma/releases/tag/3.12.0) upwards.
-
+:::
`prisma migrate deploy` issues a warning if an already applied migration has been edited - however, it does not stop the migration process. To remove the warnings, restore the original migration from source control.
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/80-unsupported-database-features.mdx b/content/200-orm/300-prisma-migrate/300-workflows/80-unsupported-database-features.mdx
index 5f5ff4a796..4e3fd00c03 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/80-unsupported-database-features.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/80-unsupported-database-features.mdx
@@ -22,12 +22,12 @@ The Prisma schema is able to represent [unsupported field types](/orm/prisma-sch
:::
-
+:::warning
This guide **does not apply for MongoDB**.
Instead of `migrate dev`, [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) is used for [MongoDB](/orm/overview/databases/mongodb).
-
+:::
diff --git a/content/200-orm/300-prisma-migrate/300-workflows/90-development-and-production.mdx b/content/200-orm/300-prisma-migrate/300-workflows/90-development-and-production.mdx
index fabec1e8dd..10049b806a 100644
--- a/content/200-orm/300-prisma-migrate/300-workflows/90-development-and-production.mdx
+++ b/content/200-orm/300-prisma-migrate/300-workflows/90-development-and-production.mdx
@@ -21,11 +21,11 @@ npx prisma migrate dev
### Create and apply migrations
-
+:::danger
`migrate dev` is a development command and should never be used in a production environment.
-
+:::
This command:
@@ -48,11 +48,11 @@ You can also `reset` the database yourself to undo manual changes or `db push` e
npx prisma migrate reset
```
-
+:::warning
`migrate reset` is a development command and should never be used in a production environment.
-
+:::
This command:
diff --git a/content/200-orm/500-reference/050-prisma-client-reference.mdx b/content/200-orm/500-reference/050-prisma-client-reference.mdx
index cc31ef781c..f92eadde2b 100644
--- a/content/200-orm/500-reference/050-prisma-client-reference.mdx
+++ b/content/200-orm/500-reference/050-prisma-client-reference.mdx
@@ -13,7 +13,8 @@ If Prisma ORM's Rust engine binaries cause large bundle sizes, slow builds, or d
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
+ provider = "prisma-client"
+ output = "./generated"
engineType = "client"
}
```
@@ -106,7 +107,7 @@ From version 5.2.0 and upwards, you can also use the [`datasourceUrl`](#datasour
##### Programmatically override a datasource `url`
```ts
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({
datasources: {
@@ -122,7 +123,6 @@ Based on the following `datasource` block:
```prisma
datasource db {
provider = "sqlite"
- url = env("DATABASE_URL")
}
```
@@ -139,7 +139,7 @@ Programmatically overrides the [`datasource`](#datasources) block in the `schema
#### Examples
```ts
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({
datasourceUrl: 'postgresql://johndoe:randompassword@localhost:5432/mydb',
@@ -208,7 +208,7 @@ export type LogEvent = {
```ts highlight=3;normal;
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({ log: ['query', 'info'] });
@@ -247,7 +247,7 @@ prisma:query SELECT COUNT(*) FROM (SELECT "public"."User"."id" FROM "public"."Us
```ts
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({
log: [{ level: 'query', emit: 'event' }],
@@ -296,7 +296,7 @@ main()
```ts
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({
log: [
@@ -415,7 +415,7 @@ The example below uses the [Neon driver adapter](/orm/overview/databases/neon#ho
```ts
import { PrismaNeon } from '@prisma/adapter-neon';
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
import dotenv from 'dotenv';
dotenv.config();
@@ -427,13 +427,13 @@ const prisma = new PrismaClient({ adapter });
### `rejectOnNotFound`
-
+:::info
-**Note**: `rejectOnNotFound` was removed in v5.0.0.
+`rejectOnNotFound` was removed in v5.0.0.
**Deprecated:** `rejectOnNotFound` is deprecated in v4.0.0. From v4.0.0, use the queries [`findUniqueOrThrow`](#finduniqueorthrow) or [`findFirstOrThrow`](#findfirstorthrow).
-
+:::
Use the `rejectOnNotFound` parameter to configure `findUnique()` and/or `findFirst` to throw an error if the record was not found. By default, both operations return `null` if the record is not found.
@@ -487,11 +487,11 @@ const prisma = new PrismaClient({
### `transactionOptions`
-
+:::info
-**Note**: `transactionOptions` was introduced in v5.10.0.
+`transactionOptions` was introduced in v5.10.0.
-
+:::
Allows to set [transaction options](/orm/prisma-client/queries/transactions#transaction-options) globally on the constructor level.
@@ -712,7 +712,7 @@ const user = await prisma.user.findFirst({
##### Get the first `Post` record where the `title` starts with `A test`, reverse the list with `take`
```ts
-import { PrismaClient } from '@prisma/client';
+import { PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({});
@@ -848,7 +848,7 @@ The following example results in **two** `INSERT` statements:
```ts
-import { Prisma, PrismaClient } from '@prisma/client';
+import { Prisma, PrismaClient } from '../prisma/generated/client';
const prisma = new PrismaClient({ log: ['query'] });
@@ -949,11 +949,11 @@ const user = await prisma.user.update({
### `upsert()`
-
+:::info
This section covers the usage of the `upsert()` operation. To learn about using [nested upsert queries](#upsert-1) within `update()`, reference the linked documentation.
-
+:::
`upsert` does the following:
@@ -2178,7 +2178,8 @@ Because the `relationLoadStrategy` option is currently in Preview, you need to e
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["relationJoins"]
}
```
@@ -2954,10 +2955,12 @@ To enable `nativeDistinct`:
```prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["nativeDistinct"]
}
```
+```
See [Preview Features](/orm/reference/preview-features/client-preview-features#preview-features-promoted-to-general-availability) for more details.
@@ -3487,11 +3490,11 @@ const user = await prisma.user.update({
### `upsert`
-
+:::info
This section covers the usage of nested upsert within `update()`. To learn about the [`upsert()`](#upsert) operation, reference the linked documentation.
-
+:::
A nested `upsert` query updates a related record if it exists, or creates a new related record.
@@ -4457,12 +4460,12 @@ const addTag = await prisma.post.update({
### `unset`
-
+:::warning
This method is available on MongoDB only in versions
[3.11.1](https://github.com/prisma/prisma/releases/tag/3.11.1) and later.
-
+:::
Use `unset` to unset the value of a scalar list. Unlike `set: null`, `unset` removes the list entirely.
@@ -4487,7 +4490,7 @@ const setTags = await prisma.post.update({
Scalar list filters allow you to filter by the contents of a list / array field.
-
+:::warning
Available for:
@@ -4495,7 +4498,7 @@ Available for:
- CockroachDB in versions [3.9.0](https://github.com/prisma/prisma/releases/tag/3.9.0) and later
- MongoDB in versions [3.11.0](https://github.com/prisma/prisma/releases/tag/3.11.0) and later
-
+:::
### Remarks
@@ -4589,12 +4592,12 @@ const posts = await prisma.post.findMany({
### `isSet`
-
+:::warning
This filter is available on MongoDB only in versions
[3.11.1](https://github.com/prisma/prisma/releases/tag/3.11.1) and later.
-
+:::
Filter lists to include only results that have been set (either set to a value, or explicitly set to `null`). Setting this filter to `true` will exclude undefined results that are not set at all.
@@ -4632,11 +4635,11 @@ const posts = await prisma.post.findMany({
## Composite type methods
-
+:::warning
Available for MongoDB only in Prisma `3.10.0` and later.
-
+:::
Composite type methods allow you to create, update and delete [composite types](/orm/prisma-client/special-fields-and-types/composite-types).
@@ -4801,11 +4804,11 @@ const product = prisma.product.update({
## Composite type filters
-
+:::warning
Available for MongoDB only in Prisma `3.11.0` and later.
-
+:::
Composite type filters allow you to filter the contents of [composite types](/orm/prisma-client/special-fields-and-types/composite-types).
@@ -5057,11 +5060,11 @@ const updatePosts = await prisma.post.updateMany({
For use cases and advanced examples, see: [Working with `Json` fields](/orm/prisma-client/special-fields-and-types/working-with-json-fields).
-
+:::warning
Supported by [PostgreSQL](/orm/overview/databases/postgresql) and [MySQL](/orm/overview/databases/mysql) with different syntaxes for the `path` option. PostgreSQL does not support filtering on object key values in arrays.
-
+:::
The examples in this section assumes that the value of the `pet` field is:
@@ -5158,11 +5161,11 @@ const getUsers = await prisma.user.findMany({
-
+:::warning
Filtering by the key values of objects inside an array (below) is only supported by the MySQL connector.
-
+:::
The following query returns all users where the nested `favorites` > `treats` array contains an object where the `name` value is `"Dreamies"`:
@@ -5345,11 +5348,11 @@ const getUsers = await prisma.user.findMany({
});
```
-
+:::info
-**Note**: In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
+In PostgreSQL, the value of `array_contains` must be an array and not a string, even if the array only contains a single value.
-
+:::
@@ -5480,13 +5483,13 @@ const getUsers = await prisma.user.findMany({
- `$on` and `$use` client methods do not exist on extended client instances which are extended using [`$extends`](#extends)
-
+:::warning
In [extended clients](/orm/prisma-client/client-extensions), Client methods do not necessarily exist. If you are extending your client, make sure to check for existence before using Client methods like `$transaction` or `$connect`.
In addition, if you are using `$on` or `$use`, you will need to use these client methods before extending your client as these methods do not exist on extended clients. For `$use` specifically we recommend transitioning [to use query extensions](/orm/prisma-client/client-extensions/query).
-
+:::
### `$disconnect()`
@@ -5506,11 +5509,11 @@ The `$connect()` method establishes a physical connection to the database via Pr
### `$on()`
-
+:::warning
`$on` is not available in [extended clients](/orm/prisma-client/client-extensions). Please either migrate to client extensions or use the `$on` method prior to extending your client.
-
+:::
The `$on()` method allows you to subscribe to [logging events](#log) or the [exit hook](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management#exit-hooks).
@@ -5595,7 +5598,7 @@ Prisma.validator(PrismaClientInstance, '', '', '
The following example shows how you can extract and validate the input for the `create` operation you can reuse within your app:
```ts
-import { Prisma } from '@prisma/client';
+import { Prisma } from '../prisma/generated/client';
const validateUserAndPostInput = (name, email, postTitle) => {
return Prisma.validator()({
@@ -5613,7 +5616,7 @@ const validateUserAndPostInput = (name, email, postTitle) => {
Here is an alternative syntax for the same operation:
```ts
-import { Prisma } from '@prisma/client';
+import { Prisma } from '../prisma/generated/client';
import prisma from './prisma';
const validateUserAndPostInput = (name, email, postTitle) => {
@@ -5640,7 +5643,7 @@ You can compare columns in the same table directly, for non-unique filters.
This feature was moved to general availability in version 5.0.0 and was available via the `fieldReference` Preview feature from Prisma ORM versions 4.3.0 to 4.16.2.
-
+:::info
In the following situations, you must [use raw queries to compare columns in the same table](/orm/more/help-and-troubleshooting/comparing-columns-through-raw-queries):
@@ -5649,7 +5652,7 @@ In the following situations, you must [use raw queries to compare columns in the
- If you want to compare a field with a [unique constraint](/orm/prisma-schema/data-model/models#defining-a-unique-field)
- If you want to use one of the following operators to compare a [JSON field](/orm/prisma-client/special-fields-and-types/working-with-json-fields) in MySQL or MariaDB with another field: [`gt`](#gt), [`gte`](#gte), [`lt`](#lt), or [`lte`](#lte). Note that you can use these operators to compare the JSON field with a scalar value. This limitation applies only if you try to compare a JSON field with another field.
-
+:::
To compare columns in the same table, use the `.fields` property. In the following example, the query returns all records where the value in the `prisma.product.quantity` field is less than or equal to the value in the `prisma.product.warnQuantity` field.
@@ -5659,11 +5662,11 @@ prisma.product.findMany({
});
```
-
+:::info
`fields` is a special property of every model. It contains the list of fields for that model.
-
+:::
### Considerations
diff --git a/content/200-orm/500-reference/100-prisma-schema-reference.mdx b/content/200-orm/500-reference/100-prisma-schema-reference.mdx
index 0a113a1579..dfb6187e6f 100644
--- a/content/200-orm/500-reference/100-prisma-schema-reference.mdx
+++ b/content/200-orm/500-reference/100-prisma-schema-reference.mdx
@@ -78,7 +78,6 @@ In this example, the target database is available with the following credentials
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
@@ -1043,12 +1042,12 @@ Not supported
### `Unsupported`
-
+:::warning
**Not supported by MongoDB**
The [MongoDB connector](/orm/overview/databases/mongodb) does not support the `Unsupported` type.
-
+:::
The `Unsupported` type was introduced in [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and allows you to represent data types in the Prisma schema that are not supported by Prisma Client. Fields of type `Unsupported` can be created during Introspection with `prisma db pull` or written by hand, and created in the database with Prisma Migrate or `db push`.
@@ -1301,7 +1300,7 @@ model User {
}
```
-
+:::warning
You cannot use `cuid()` to generate a default value if your `id` field is of type `ObjectId`. Use the following syntax to generate a valid `ObjectId`:
@@ -1309,7 +1308,7 @@ You cannot use `cuid()` to generate a default value if your `id` field is of typ
id String @id @default(auto()) @db.ObjectId @map("_id")
```
-
+:::
@@ -1338,7 +1337,7 @@ model User {
}
```
-
+:::warning
You cannot use `uuid()` to generate a default value if your `id` field is of type `ObjectId`. Use the following syntax to generate a valid `ObjectId`:
@@ -1346,7 +1345,7 @@ You cannot use `uuid()` to generate a default value if your `id` field is of typ
id String @id @default(auto()) @db.ObjectId @map("_id")
```
-
+:::
@@ -1375,7 +1374,7 @@ model User {
}
```
-
+:::warning
You cannot use `ulid()` to generate a default value if your `id` field is of type `ObjectId`. Use the following syntax to generate a valid `ObjectId`:
@@ -1383,7 +1382,7 @@ You cannot use `ulid()` to generate a default value if your `id` field is of typ
id String @id @default(auto()) @db.ObjectId @map("_id")
```
-
+:::
@@ -1512,12 +1511,12 @@ const profileWithUser = await prisma.profile.create({
### `@@id`
-
+:::warning
**Not supported by MongoDB**
The [MongoDB connector](/orm/overview/databases/mongodb) does not support composite IDs.
-
+:::
Defines a multi-field ID (composite ID) on the model.
@@ -2468,11 +2467,11 @@ Defines an index in the database.
- Define partial indexes with `WHERE`
- Create indexes concurrently with `CONCURRENTLY`
-
+:::info
While you cannot configure these option in your Prisma schema, you can still configure them on the database-level directly.
-
+:::
##### MongoDB
@@ -2968,12 +2967,12 @@ The name of the `name` argument on the `@@schema` attribute can be omitted
```prisma highlight=3,9,16;normal
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
//highlight-next-line
schemas = ["auth"]
}
@@ -2987,11 +2986,11 @@ model User {
}
```
-
+:::info
For more information about using the `multiSchema` feature, refer to [this guide](/orm/prisma-schema/data-model/multi-schema).
-
+:::
### `@shardKey`
@@ -2999,7 +2998,7 @@ For more information about using the `multiSchema` feature, refer to [this guide
This features requires the `shardKeys` Preview feature flag on your `generator`:
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
output = "../generated/prisma"
previewFeatures = ["shardKeys"]
}
@@ -3022,7 +3021,7 @@ model User {
This features requires the `shardKeys` Preview feature flag on your `generator`:
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
output = "../generated/prisma"
previewFeatures = ["shardKeys"]
}
@@ -3044,7 +3043,9 @@ model User {
### `auto()`
-This function is available on MongoDB only.
+:::warning
+This function is available on MongoDB only.
+:::
Represents **default values** that are automatically generated by the database.
@@ -3075,12 +3076,12 @@ model User {
### `autoincrement()`
-
+:::warning
**Not supported by MongoDB**
The [MongoDB connector](/orm/overview/databases/mongodb) does not support the `autoincrement()` function.
-
+:::
Create a sequence of integers in the underlying database and assign the incremented values to the ID values of the created records based on the sequence.
@@ -3109,12 +3110,12 @@ model User {
### `sequence()`
-
+:::info
**Only supported by CockroachDB**
The sequence function is only supported by [CockroachDB connector](/orm/overview/databases/cockroachdb).
-
+:::
Create a sequence of integers in the underlying database and assign the incremented values to the values of the created records based on the sequence.
@@ -3475,11 +3476,11 @@ model User {
}
```
-
+:::info
-**Note**: [`gen_random_uuid()` is a PostgreSQL function](https://www.postgresql.org/docs/13/functions-uuid.html). To use it in PostgreSQL versions 12.13 and earlier, you must enable the `pgcrypto` extension.
In Prisma ORM versions 4.5.0 and later, you can declare the `pgcrypto` extension in your Prisma schema with the [`postgresqlExtensions` preview feature](/orm/prisma-schema/postgresql-extensions).
+[`gen_random_uuid()` is a PostgreSQL function](https://www.postgresql.org/docs/13/functions-uuid.html). To use it in PostgreSQL versions 12.13 and earlier, you must enable the `pgcrypto` extension.
In Prisma ORM versions 4.5.0 and later, you can declare the `pgcrypto` extension in your Prisma schema with the [`postgresqlExtensions` preview feature](/orm/prisma-schema/postgresql-extensions).
-
+:::
## Attribute argument types
@@ -3497,12 +3498,12 @@ An expression that can be evaluated by Prisma ORM: `42.0`, `""`, `Bob`, `now()`,
## `enum`
-
+:::warning
**Not supported Microsoft SQL Server**
The [Microsoft SQL Server connector](/orm/overview/databases/sql-server) does not support the `enum` type.
-
+:::
Defines an [enum](/orm/prisma-schema/data-model/models#defining-enums) .
@@ -3591,17 +3592,17 @@ model User {
## `type`
-
+:::warning
Composite types are available **for MongoDB only**.
-
+:::
-
+:::info
Composite types are available in versions 3.12.0 and later, and in versions 3.10.0 and later if you enable the `mongodb` Preview feature flag.
-
+:::
Defines a [composite type](/orm/prisma-schema/data-model/models#defining-composite-types) .
diff --git a/content/200-orm/500-reference/200-prisma-cli-reference.mdx b/content/200-orm/500-reference/200-prisma-cli-reference.mdx
index 31b6eb1914..6f636d254c 100644
--- a/content/200-orm/500-reference/200-prisma-cli-reference.mdx
+++ b/content/200-orm/500-reference/200-prisma-cli-reference.mdx
@@ -133,7 +133,7 @@ By default, the project sets up a [local Prisma Postgres](/postgres/database/loc
| `--db` | No | Shorthand syntax for `--datasource-provider prisma+postgres`; creates a new [Prisma Postgres](/postgres) instance. Requires authentication in the [PDP Console](https://console.prisma.io). | |
| `--prompt` (or `--vibe`) | No | Scaffolds a Prisma schema based on the prompt and deploys it to a fresh Prisma Postgres instance. Requires authentication in the [PDP Console](https://console.prisma.io). | |
| `--url` | No | Define a custom `datasource` url. | |
-| `--generator-provider` | No | Define the generator provider to use. | `prisma-client-js` |
+| `--generator-provider` | No | Define the generator provider to use. | `prisma-client` |
| `--preview-feature` | No | Define the [Preview features](/orm/reference/preview-features) to use. To define multiple Preview features, you have to provide the flag multiple times for each Preview feature. See examples. | |
| `--output` | No | Specifies the [output location for the generated client](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path). | `../generated/prisma` |
| `--with-model` | No | Adds a simple `User` model to the initial Prisma schema. Available since version `5.14.0`. | |
@@ -215,11 +215,11 @@ prisma init --preview-feature metrics
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["metrics"]
}
```
@@ -243,11 +243,11 @@ prisma init --preview-feature view --preview-feature metrics
```prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["views", "metrics"]
}
```
@@ -267,13 +267,12 @@ An initial `schema.prisma` file to define your schema in:
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
@@ -323,11 +322,11 @@ A minimal `schema.prisma` file to define your schema in:
datasource db {
provider = "mysql"
- url = env("DATABASE_URL")
}
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
```
@@ -350,19 +349,19 @@ DATABASE_URL="mysql://user:password@localhost:3306/mydb"
The `generate` command generates assets like Prisma Client based on the [`generator`](/orm/prisma-schema/overview/generators) and [`data model`](/orm/prisma-schema/data-model/models) blocks defined in your `prisma/schema.prisma` file.
-The `generate` command is most often used to generate Prisma Client with the `prisma-client-js` generator. This does three things:
+The `generate` command is most often used to generate Prisma Client with the `prisma-client` generator. This does the following:
-1. Searches the current directory and parent directories to find the applicable `npm` project. It will create a `package.json` file in the current directory if it cannot find one.
-2. Installs the `@prisma/client` into the `npm` project if it is not already present.
-3. Inspects the current directory to find a Prisma Schema to process. It will then generate a customized [Prisma Client](https://github.com/prisma/prisma-client-js) for your project.
+1. Inspects the current directory to find a Prisma Schema to process.
+2. Generates a customized Prisma Client based on your schema into the output directory specified in the generator block.
#### Prerequisites
-To use the `generate` command, you must add a generator definition in your `schema.prisma` file. The `prisma-client-js` generator, used to generate Prisma Client, can be added by including the following in your `schema.prisma` file:
+To use the `generate` command, you must add a generator definition in your `schema.prisma` file. The `prisma-client` generator, used to generate Prisma Client, can be added by including the following in your `schema.prisma` file:
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
```
@@ -413,7 +412,7 @@ prisma generate
You can now start using Prisma Client in your code:
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
@@ -469,7 +468,7 @@ prisma generate --generator client --generator zod_schemas
#### Generated Assets
-The `prisma-client-js` generator creates a customized client for working with your database within the `./node_modules/.prisma/client` directory by default - you can [customize the output folder](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path).
+The `prisma-client` generator creates a customized client for working with your database in a custom output directory specified by the `output` field - you can [customize the output folder](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path).
### `validate`
@@ -524,7 +523,7 @@ Error code: P1012
error: The preview feature "unknownFeatureFlag" is not known. Expected one of: [...]
--> schema.prisma:3
|
- 2 | provider = "prisma-client-js"
+ 2 | provider = "prisma-client"
3 | previewFeatures = ["unknownFeatureFlag"]
|
@@ -591,7 +590,7 @@ Error code: P1012
error: The preview feature "unknownFeatureFlag" is not known. Expected one of: [...]
--> schema.prisma:3
|
- 2 | provider = "prisma-client-js"
+ 2 | provider = "prisma-client"
3 | previewFeatures = ["unknownFeatureFlag"]
|
@@ -923,7 +922,8 @@ prisma db pull --print
```prisma no-copy
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
diff --git a/content/200-orm/500-reference/250-error-reference.mdx b/content/200-orm/500-reference/250-error-reference.mdx
index fefd1fd8bd..7b1d484872 100644
--- a/content/200-orm/500-reference/250-error-reference.mdx
+++ b/content/200-orm/500-reference/250-error-reference.mdx
@@ -334,11 +334,11 @@ Possible P1012 error messages:
### Prisma Migrate (Schema Engine)
-
+:::warning
The Schema Engine was previously called Migration Engine. This change was introduced in version [5.0.0](https://github.com/prisma/prisma/releases/tag/5.0.0).
-
+:::
#### `P3000`
diff --git a/content/200-orm/500-reference/300-environment-variables-reference.mdx b/content/200-orm/500-reference/300-environment-variables-reference.mdx
index 9bc8dcc2a2..fb3d680d86 100644
--- a/content/200-orm/500-reference/300-environment-variables-reference.mdx
+++ b/content/200-orm/500-reference/300-environment-variables-reference.mdx
@@ -84,7 +84,6 @@ Disables all CLI warnings generated by `logger.warn`.
### `PRISMA_GENERATE_NO_ENGINE`
-
:::danger Prisma v7 deprecation
This environment variable is only supported in Prisma 6.19 and earlier. It will not work in Prisma v7.
diff --git a/content/200-orm/500-reference/325-prisma-config-reference.mdx b/content/200-orm/500-reference/325-prisma-config-reference.mdx
index 713ec76d34..24a14d6ee7 100644
--- a/content/200-orm/500-reference/325-prisma-config-reference.mdx
+++ b/content/200-orm/500-reference/325-prisma-config-reference.mdx
@@ -440,6 +440,7 @@ Configure the schema engine your project should use.
By default it is set to use the classic engine, which requires that `datasource` be set in your `prisma.config.ts`.
```ts
+import 'dotenv/config'
import path from "node:path";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
diff --git a/content/200-orm/500-reference/380-connection-urls.mdx b/content/200-orm/500-reference/380-connection-urls.mdx
index a8bf1b54a9..d68457494b 100644
--- a/content/200-orm/500-reference/380-connection-urls.mdx
+++ b/content/200-orm/500-reference/380-connection-urls.mdx
@@ -156,7 +156,6 @@ You can also provide the connection URL as an environment variable:
```prisma file=schema.prisma
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
diff --git a/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx b/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx
index 1ea24923c5..f4f60abfc8 100644
--- a/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx
+++ b/content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx
@@ -33,7 +33,8 @@ To enable a Prisma Client Preview feature:
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
previewFeatures = ["relationJoins"]
}
```
diff --git a/content/200-orm/800-more/100-under-the-hood/100-engines.mdx b/content/200-orm/800-more/100-under-the-hood/100-engines.mdx
index 78d23be5a0..b9c43e8272 100644
--- a/content/200-orm/800-more/100-under-the-hood/100-engines.mdx
+++ b/content/200-orm/800-more/100-under-the-hood/100-engines.mdx
@@ -294,8 +294,9 @@ When using Rust-based engines, you can choose between a Node-API library or an e
```prisma
generator client {
- provider = "prisma-client-js" // or "prisma-client"
- engineType = "binary" // or "library" for Rust-based engines
+ provider = "prisma-client"
+ output = "./generated"
+ engineType = "binary"
}
```
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/101-jsonprotocol-changes.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/101-jsonprotocol-changes.mdx
index 9b21076af3..acf128027f 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/101-jsonprotocol-changes.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/101-jsonprotocol-changes.mdx
@@ -204,11 +204,11 @@ prisma.user.findMany({
})
```
-
+:::info
Note: This `path` argument change only affects PostgreSQL databases. MySQL databases are not affected as they use a different syntax.
-
+:::
#### Scalar lists
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx
index 10454a4417..ea3e59c462 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/600-upgrading-to-prisma-5/index.mdx
@@ -43,11 +43,11 @@ pnpm upgrade prisma@5 @prisma/client@5
-
+:::danger
Before you upgrade, check each breaking change below to see how the upgrade might affect your application.
-
+:::
## Version changes
@@ -58,11 +58,11 @@ See our [system requirements](/orm/reference/system-requirements) for all minimu
From Prisma ORM version 5.0.0, the minimum version of Node.js supported is 16.13.0. If your project uses an earlier version of Node.js, you will need to upgrade it.
-
+:::warning
Node.js v16.x is reaching [end-of-life on 11 September 2023](https://nodejs.org/en/blog/announcements/nodejs16-eol) in order to coincide with the end-of-life of OpenSSL 1.1.1. For that reason, we recommend upgrading to the current Node.js LTS, v18.x. Please note that Prisma ORM 5 will be the last major version of Prisma ORM to support Node.js v16.
-
+:::
### TypeScript minimum version change
@@ -72,11 +72,11 @@ From Prisma ORM version 5.0.0, the minimum version of TypeScript supported is 4.
From Prisma ORM version 5.0.0, the minimum version of PostgreSQL supported is 9.6. If your project uses an earlier version of PostgreSQL, you will need to upgrade it.
-
+:::warning
While Prisma ORM supports PostgreSQL versions 9.6 and above, we **strongly** recommend updating to a version that is currently supported and still receiving updates. Please check [PostgreSQL's versioning policy](https://www.postgresql.org/support/versioning/) to determine which versions are currently supported.
-
+:::
### Prisma Client embedded SQLite version updated
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx
index ff95e20ff9..4abaf62f5f 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx
@@ -451,11 +451,11 @@ To upgrade to Prisma ORM 4 from an earlier version, you need to update both the
To ignore the caret `^` and upgrade across major versions, you can use the `@4` tag when you upgrade with `npm`, or `yarn`:
-
+:::danger
Before you upgrade, check each **breaking change** to see how the upgrade might affect your application.
-
+:::
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx
index a099b97d22..af110627d1 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx
@@ -57,11 +57,11 @@ When you run an Introspection, Prisma ORM compares all the foreign keys in the d
After introspecting, you can review the non-default clauses in your schema. The most important clause to review is `onDelete`, which defaults to `Cascade` in version 2.25.0 and earlier.
-
+:::danger
If you are using either the [`delete()`](/orm/prisma-client/queries/crud#delete-a-single-record) or [`deleteAll()`](/orm/prisma-client/queries/crud#delete-all-records) methods, **cascading deletes will now be performed, as the safety net in Prisma Client that previously prevented cascading deletes at runtime is removed**. Be sure to check your code and make any adjustments accordingly.
-
+:::
Make sure you are happy with every case of `onDelete: Cascade` in your schema. If not, either:
@@ -91,12 +91,12 @@ model User {
When running a [Migration](/orm/prisma-migrate) (or the [`prisma db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) command) the [new defaults](/orm/prisma-schema/data-model/relations/referential-actions#referential-action-defaults) will be applied to your database.
-
+:::info
Unlike when you run `prisma db pull` for the first time, the new referential actions clause and property will **not** automatically be added to your Prisma schema by the Prisma VSCode extension.
You will have to manually add them if you wish to use anything other than the new defaults.
-
+:::
Explicitly defining referential actions in your Prisma schema is optional. If you do not explicitly define a referential action for a relation, Prisma ORM uses the [new defaults](/orm/prisma-schema/data-model/relations/referential-actions#referential-action-defaults).
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx
index 2180704600..059b79c98f 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx
@@ -116,13 +116,13 @@ prisma.log.create({
})
```
-
+:::warning
This API change does not apply to the MongoDB connector where there is not a difference between a JSON null and a database NULL.
They also do not apply to the `array_contains` operator because there can only be a JSON null within an JSON array. Since there cannot be a database NULL within a JSON array, `{ array_contains: null }` is not ambiguous.
-
+:::
## Specific upgrade paths
@@ -134,11 +134,11 @@ To upgrade from version 2.x to 3.x, you need to update both the `prisma` and `@p
To ignore the caret `^` and upgrade across major versions, you can use the `@3` tag when upgrading with `npm`, or `yarn` .
-
+:::danger
Before upgrading, check each **breaking change** to see how the upgrade might affect your application.
-
+:::
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/900-codemods.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/900-codemods.mdx
index df3c620c2f..c103ccf427 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/900-codemods.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/900-codemods.mdx
@@ -8,11 +8,11 @@ metaDescription: 'Use codemods to upgrade your codebase as Prisma ORM evolves.'
The `@prisma/codemods` package helps you to upgrade your codebase as Prisma ORM evolves.
-
+:::info
You can checkout the repository, here: https://github.com/prisma/codemods
-
+:::
diff --git a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx
index a207ab3508..5276ab1701 100644
--- a/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/index.mdx
@@ -45,8 +45,8 @@ To install the latest `dev` distribution tag:
npm install @prisma/client@dev prisma@dev
```
-
+:::danger
Do not use the `dev` distribution tag in production - wait until the official release that contains the features and fixes you are interested in is released. For example, fixes present `@prisma/client@2.23.0-dev.25` will eventually be released as part of `@prisma/client@2.23.0`.
-
+:::
diff --git a/content/200-orm/800-more/300-upgrade-guides/250-upgrading-to-use-preview-features.mdx b/content/200-orm/800-more/300-upgrade-guides/250-upgrading-to-use-preview-features.mdx
index 816fd2be41..bdd474e310 100644
--- a/content/200-orm/800-more/300-upgrade-guides/250-upgrading-to-use-preview-features.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/250-upgrading-to-use-preview-features.mdx
@@ -18,8 +18,8 @@ Some releases include Preview features that are not considered production-ready,
- [Enable Prisma Client and schema preview features](/orm/reference/preview-features/client-preview-features)
- [Enable Prisma CLI preview features](/orm/reference/preview-features/cli-preview-features)
-
+:::warning
We do not recommend using Preview features in production.
-
+:::
diff --git a/content/200-orm/800-more/300-upgrade-guides/800-upgrade-from-prisma-1/08-upgrade-from-mongodb-beta.mdx b/content/200-orm/800-more/300-upgrade-guides/800-upgrade-from-prisma-1/08-upgrade-from-mongodb-beta.mdx
index 4358dc8ae2..7e0161a6e8 100644
--- a/content/200-orm/800-more/300-upgrade-guides/800-upgrade-from-prisma-1/08-upgrade-from-mongodb-beta.mdx
+++ b/content/200-orm/800-more/300-upgrade-guides/800-upgrade-from-prisma-1/08-upgrade-from-mongodb-beta.mdx
@@ -12,10 +12,10 @@ The scope of this guide is to give you the workflow necessary to perform the mig
We unfortunately can't cover all possible scenarios or changes required, but this guide should help you on your journey. Join [our Discord](https://pris.ly/discord?utm_source=docs&utm_medium=intro_text) or create an issue [on Github](https://github.com/prisma/prisma1/issues/new/choose) with any questions.
-
+:::warning
Perform this migration on your staging environment before trying this in
production!
-
+:::
## Requirements
@@ -37,7 +37,7 @@ This should create the following files:
- `prisma/schema.prisma`: An initial Prisma schema
- `.env`: Environment file where you'll store your connection string
-
+:::info
If you see the following error:
@@ -48,7 +48,7 @@ Please try again in a project that is not yet using Prisma.
You have likely a `prisma/` directory in your project already. Rename that directory to something like `_prisma/` and try again
-
+:::
## Find the Connection String to your MongoDB Database
@@ -74,11 +74,11 @@ $ npx prisma db pull
And you should see your Prisma schema in `prisma/schema.prisma` populated with your models.
-
+:::info
If you see the following error: `Error in connector: SCRAM failure: Authentication failed.`, try adding `?authSource=admin` to the end of your connection string and trying again.
-
+:::
## Touching up your Prisma Schema
@@ -112,11 +112,11 @@ Unlike SQL databases, MongoDB doesn't have an explicit understanding of relation
We typically recommend adding the relationships by hand with the help of [this documentation](/orm/overview/databases/mongodb#how-to-add-in-missing-relations-after-introspection). However, Prisma 1 stores foreign keys is different than where Prisma ORM 2 and later expects foreign keys, so if you want to take advantage of relationships, you'll need to shift where the foreign keys are on your database before adding the relationships.
-
+:::tip
💡 Download the Prisma VSCode Extension to provide autocomplete and helpful error messages as you transition your Prisma schema.
-
+:::
## Generating a Prisma Client
@@ -211,7 +211,7 @@ main()
And you should see a user was created.
-
+:::warning
If you see the following error:
@@ -221,7 +221,7 @@ Prisma needs to perform transactions, which requires your MongoDB server to be r
This means that your MongoDB database isn't running as a replica set. Refer to [the link above](https://pris.ly/d/mongodb-replica-set) for steps to resolve this issue.
-
+:::
## Upgrading your Application
diff --git a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx
index 2ab60d89ab..97b1b6fbb5 100644
--- a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx
+++ b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx
@@ -206,12 +206,12 @@ If you run the prompts below, you may receive a different outputs because LLMs p
```prisma file=schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
@@ -341,7 +341,7 @@ import {
UserRole,
SubscriptionPlan,
SubscriptionStatus,
-} from "@prisma/client";
+} from "../prisma/generated/client";
const prisma = new PrismaClient();
diff --git a/content/200-orm/800-more/350-ai-tools/200-tabnine.mdx b/content/200-orm/800-more/350-ai-tools/200-tabnine.mdx
index 63c470a872..c67ad37b70 100644
--- a/content/200-orm/800-more/350-ai-tools/200-tabnine.mdx
+++ b/content/200-orm/800-more/350-ai-tools/200-tabnine.mdx
@@ -56,12 +56,12 @@ _Define a Prisma schema for a SaaS application with User, Organization, and Subs
```prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
@@ -316,8 +316,8 @@ GROUP BY status;
#### Application code
```ts
-import { PrismaClient } from '@prisma/client'
-import { subscriptionsReport } from '@prisma/client/sql'
+import { PrismaClient } from '../prisma/generated/client'
+import { subscriptionsReport } from '../prisma/generated/client/sql'
const prisma = new PrismaClient();
@@ -416,7 +416,7 @@ _Generate a Prisma seed script for populating User, Organization, and Subscripti
#### Generated code
```ts
-import { PrismaClient } from "@prisma/client";
+import { PrismaClient } from "../prisma/generated/client";
const prisma = new PrismaClient();
diff --git a/content/200-orm/800-more/350-ai-tools/300-windsurf.mdx b/content/200-orm/800-more/350-ai-tools/300-windsurf.mdx
index 814c77f782..35aacddc1d 100644
--- a/content/200-orm/800-more/350-ai-tools/300-windsurf.mdx
+++ b/content/200-orm/800-more/350-ai-tools/300-windsurf.mdx
@@ -233,12 +233,12 @@ LLMs may produce different results each time, even with the same prompt.
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
@@ -365,7 +365,7 @@ import {
UserRole,
SubscriptionPlan,
SubscriptionStatus,
-} from "@prisma/client";
+} from "../prisma/generated/client";
const prisma = new PrismaClient();
diff --git a/content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx b/content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx
index 740f3b9305..ea70d9b59e 100644
--- a/content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx
+++ b/content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx
@@ -137,7 +137,7 @@ You can tailor Copilot Chat's behavior in your repository by [adding a `.github/
```ts
// prisma.ts
- import { PrismaClient } from '@prisma/client';
+ import { PrismaClient } from '../prisma/generated/client';
export const prisma = global.prisma || new PrismaClient();
if (process.env.NODE_ENV !== 'production') global.prisma = prisma;
/```
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/100-autocompletion-in-graphql-resolvers-with-js.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/100-autocompletion-in-graphql-resolvers-with-js.mdx
index 912ecb7d92..963f8db2eb 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/100-autocompletion-in-graphql-resolvers-with-js.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/100-autocompletion-in-graphql-resolvers-with-js.mdx
@@ -39,7 +39,7 @@ To overcome this, you need to add a [JSDoc](https://jsdoc.app/) comment named `t
// Add this to the top of the file
/**
- * @typedef { import("@prisma/client").PrismaClient } Prisma
+ * @typedef { import("../prisma/generated/client").PrismaClient } Prisma
*/
```
@@ -75,8 +75,8 @@ The final file should look something like:
```js
/**
- * @typedef { import("@prisma/client").PrismaClient } Prisma
- * @typedef { import("@prisma/client").UserCreateArgs } UserCreateArgs
+ * @typedef { import("../prisma/generated/client").PrismaClient } Prisma
+ * @typedef { import("../prisma/generated/client").UserCreateArgs } UserCreateArgs
*/
const { makeExecutableSchema } = require('graphql-tools')
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/300-implicit-to-explicit-conversion.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/300-implicit-to-explicit-conversion.mdx
index b65c07c74f..fcdc3a5c1b 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/300-implicit-to-explicit-conversion.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/300-implicit-to-explicit-conversion.mdx
@@ -76,7 +76,7 @@ To migrate the existing data from the implicit relation table to the new explici
Considering the above `User` and `Post` models, here’s an example script you can use to migrate data.
```typescript
-import { PrismaClient } from "@prisma/client";
+import { PrismaClient } from "../prisma/generated/client";
const prisma = new PrismaClient();
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/400-nextjs-help.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/400-nextjs-help.mdx
index 075f318eb0..19dc9c0bfc 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/400-nextjs-help.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/400-nextjs-help.mdx
@@ -31,7 +31,7 @@ To avoid this, create a single Prisma Client instance by using a global variable
```typescript
// lib/prisma.ts
-import { PrismaClient } from "@prisma/client";
+import { PrismaClient } from "../prisma/generated/client";
const globalForPrisma = global as unknown as { prisma: PrismaClient };
@@ -91,7 +91,7 @@ Use a factory function to dynamically create Prisma Clients based on tenant-spec
```typescript
// lib/prismaDynamic.ts
-import { PrismaClient } from "@prisma/client";
+import { PrismaClient } from "../prisma/generated/client";
type TenantConfig = {
databaseUrl: string;
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/500-comparing-columns-through-raw-queries.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/500-comparing-columns-through-raw-queries.mdx
index 146867f787..23df2ec3d1 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/500-comparing-columns-through-raw-queries.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/500-comparing-columns-through-raw-queries.mdx
@@ -20,11 +20,11 @@ Comparing values from two columns in the same table can be achieved by using [ra
### Comparing numeric values
-
+:::info
From version 4.3.0, you do not need to use raw queries to compare columns in the same table. You can use the `.fields` property to compare the columns. [Learn more](/orm/reference/prisma-client-reference#compare-columns-in-the-same-table)
-
+:::
One use case for comparing values from different columns would be retrieving posts that have more comments than likes; in this case, you need to compare the values of `commentsCount` and `likesCount`.
@@ -48,7 +48,7 @@ Queries (depending upon which database) could look something like:
_PostgreSQL / CockroachDB_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -65,7 +65,7 @@ await initiateNumbersComparisonRawQuery()
_MySQL_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -82,7 +82,7 @@ await initiateNumbersComparisonRawQuery()
_Sqlite_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -118,11 +118,11 @@ _Query Response_
### Comparing date values
-
+:::info
From version 4.3.0, you do not need to use raw queries to compare columns in the same table. You can use the `.fields` property to compare the columns. [Learn more](/orm/reference/prisma-client-reference#compare-columns-in-the-same-table)
-
+:::
Similarly, if you need to compare dates, you could also achieve the same thing using raw queries.
@@ -145,7 +145,7 @@ Queries (depending upon the database) could look something like:
_PostgreSQL / CockroachDB_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -162,7 +162,7 @@ await initiateDatesComparisonRawQuery()
_MySQL_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
@@ -179,7 +179,7 @@ await initiateDatesComparisonRawQuery()
_Sqlite_
```js
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prisma = new PrismaClient()
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/600-vercel-caching-issue.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/600-vercel-caching-issue.mdx
index 5061c15778..d4d1fc6f08 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/600-vercel-caching-issue.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/600-vercel-caching-issue.mdx
@@ -56,11 +56,11 @@ You can configure the deployment to run this command in multiple different ways:
### A custom `postinstall` script
-
+:::info
This is the preferred method as it is a universal solution.
-
+:::
Within the `scripts` section of your project's `package.json` file, if there is not already a script named `postinstall`, add one and add `prisma generate` to that script:
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/700-netlify-caching-issue.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/700-netlify-caching-issue.mdx
index 3285593ac5..ed7836a4bd 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/700-netlify-caching-issue.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/700-netlify-caching-issue.mdx
@@ -54,11 +54,11 @@ You can configure the deployment to run this command in multiple different ways:
### A custom `postinstall` script
-
+:::info
This is the preferred method as it is a universal solution.
-
+:::
Within the `scripts` section of your project's `package.json` file, if there is not already a script named `postinstall`, add one and add prisma generate` in that script:
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/800-check-constraints.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/800-check-constraints.mdx
index 2166927bc6..a4dc7b9815 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/800-check-constraints.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/800-check-constraints.mdx
@@ -260,7 +260,6 @@ Create a new file named `schema.prisma` and add the following code to it:
```prisma file=schema.prisma showLineNumbers
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
```
@@ -288,12 +287,12 @@ This command introspects your database and for each table adds a Prisma model to
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model anotherproduct {
@@ -328,7 +327,8 @@ First, add a `generator` block to your Prisma schema (typically added right belo
```prisma file=schema.prisma showLineNumbers
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
```
@@ -345,7 +345,7 @@ Now you can use Prisma Client to send database queries in Node.js.
Create a new file named `index.js` and add the following code to it:
```js
-const { PrismaClient } = require('@prisma/client')
+const { PrismaClient } = require('../prisma/generated/client')
const prisma = new PrismaClient()
@@ -380,7 +380,7 @@ ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error
To validate the multi-column check constraint, replace the code in `index.js` with the following:
```js
-const { PrismaClient } = require('@prisma/client')
+const { PrismaClient } = require('../prisma/generated/client')
const prisma = new PrismaClient()
@@ -416,7 +416,7 @@ ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error
Finally, modify the script to include multiple check constraint violations:
```js
-const { PrismaClient } = require('@prisma/client')
+const { PrismaClient } = require('../prisma/generated/client')
const prisma = new PrismaClient()
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/900-prisma-nuxt-module.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/900-prisma-nuxt-module.mdx
index b6fa843888..93b0615b4d 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/900-prisma-nuxt-module.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/900-prisma-nuxt-module.mdx
@@ -51,12 +51,12 @@ This module provides several features to streamline the setup and usage of Prism
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "sqlite"
- url = env("DATABASE_URL")
}
model User {
@@ -76,9 +76,9 @@ This module provides several features to streamline the setup and usage of Prism
}
```
4. Prompt you to run a migration to create database tables with [Prisma Migrate](/orm/prisma-migrate/understanding-prisma-migrate/overview)
-
+ :::note
The database migrates automatically the first time you start the module if there isn't a `migrations` folder. After that, you need to run `npx prisma migrate dev` manually in the CLI to apply any schema changes. Running the `npx prisma migrate dev` command manually makes it easier and safer to manage migrations and also to [troubleshoot](/orm/prisma-migrate/workflows/troubleshooting) any migration-related errors.
-
+ :::
5. Install and generate a [Prisma Client](/orm/reference/prisma-client-reference) which enables you to query your DB
6. Automatically start [Prisma Studio](/orm/tools/prisma-studio)
@@ -103,12 +103,12 @@ To configure [the getting started example](#getting-started) to use a PostgreSQL
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
datasource db {
provider = "postgresql"
- url = env("DATABASE_URL")
}
model User {
@@ -190,7 +190,7 @@ If you're using [Nuxt server components](https://nuxt.com/docs/guide/directory-s
After running through the initial setup prompts, this module creates the `lib/prisma.ts` file which contains a global instance of Prisma Client.
```typescript file=lib/prisma.ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const prismaClientSingleton = () => {
return new PrismaClient()
@@ -210,7 +210,7 @@ if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
You can customize Prisma Client's capabilities by using client extensions in your `lib/prisma.ts` file. Here is an example using the [Accelerate client extension](https://www.npmjs.com/package/@prisma/extension-accelerate):
```typescript file=lib/prisma.ts
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'
const prismaClientSingleton = () => {
@@ -274,9 +274,9 @@ export default defineNuxtConfig({
})
```
-
+:::note
The `prisma` key is available in `nuxt.config.ts` after successfully setting up the module by running `npm run dev`
-
+:::
| Option | Type | Default | Description |
|---------------------|-----------|---------|-------------|
@@ -366,7 +366,8 @@ Please try delete `output = ../generated/prisma` in schema.prisma, like
```prisma file=prisma/schema.prisma
generator client {
- provider = "prisma-client-js"
+ provider = "prisma-client"
+ output = "./generated"
}
```
diff --git a/content/200-orm/800-more/600-help-and-troubleshooting/950-typescript-performance-optimization.mdx b/content/200-orm/800-more/600-help-and-troubleshooting/950-typescript-performance-optimization.mdx
index 4cd6f46770..ba4de7c29e 100644
--- a/content/200-orm/800-more/600-help-and-troubleshooting/950-typescript-performance-optimization.mdx
+++ b/content/200-orm/800-more/600-help-and-troubleshooting/950-typescript-performance-optimization.mdx
@@ -70,7 +70,7 @@ The solution involves using TypeScript's `typeof` operator instead of direct typ
### Problematic approach for large schemas
```typescript
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const saveFn = async (prismaClient: PrismaClient) => {
// Function implementation
@@ -89,7 +89,7 @@ await saveFn(client)
### Optimized approach with `typeof`
```typescript
-import { PrismaClient } from '@prisma/client'
+import { PrismaClient } from '../prisma/generated/client'
const saveFn = async (prismaClient: typeof client) => {
// Function implementation
diff --git a/package-lock.json b/package-lock.json
index 128d01fdb5..687dafc3fe 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -248,6 +248,7 @@
"resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.40.0.tgz",
"integrity": "sha512-nlr/MMgoLNUHcfWC5Ns2ENrzKx9x51orPc6wJ8Ignv1DsrUmKm0LUih+Tj3J+kxYofzqQIQRU495d4xn3ozMbg==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@algolia/client-common": "5.40.0",
"@algolia/requester-browser-xhr": "5.40.0",
@@ -373,6 +374,7 @@
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.4.tgz",
"integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.3",
@@ -2313,6 +2315,7 @@
}
],
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=18"
},
@@ -2335,6 +2338,7 @@
}
],
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=18"
}
@@ -2444,6 +2448,7 @@
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz",
"integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
@@ -2865,6 +2870,7 @@
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz",
"integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
@@ -3547,6 +3553,7 @@
"resolved": "https://registry.npmjs.org/@docusaurus/core/-/core-3.9.1.tgz",
"integrity": "sha512-FWDk1LIGD5UR5Zmm9rCrXRoxZUgbwuP6FBA7rc50DVfzqDOMkeMe3NyJhOsA2dF0zBE3VbHEIMmTjKwTZJwbaA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@docusaurus/babel": "3.9.1",
"@docusaurus/bundler": "3.9.1",
@@ -3623,6 +3630,7 @@
"resolved": "https://registry.npmjs.org/@docusaurus/faster/-/faster-3.9.1.tgz",
"integrity": "sha512-zJIrIv+R/IN5TTLV9L+SvO3hwz62L6pO/L16k+b2nC3to3Gn01cnEGHL6doTGAezuPwTSmteJl+kzaoOf+znzg==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@docusaurus/types": "3.9.1",
"@rspack/core": "^1.5.0",
@@ -3751,6 +3759,7 @@
"resolved": "https://registry.npmjs.org/@docusaurus/plugin-content-docs/-/plugin-content-docs-3.9.1.tgz",
"integrity": "sha512-DyLk9BIA6I9gPIuia8XIL+XIEbNnExam6AHzRsfrEq4zJr7k/DsWW7oi4aJMepDnL7jMRhpVcdsCxdjb0/A9xg==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@docusaurus/core": "3.9.1",
"@docusaurus/logger": "3.9.1",
@@ -5531,6 +5540,7 @@
"resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.1.1.tgz",
"integrity": "sha512-f++rKLQgUVYDAtECQ6fn/is15GkEH9+nZPM3MS0RcxVqoTfawHvDlSCH7JbMhAM6uJ32v3eXLvLmLvjGu7PTQw==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/mdx": "^2.0.0"
},
@@ -6751,6 +6761,7 @@
"resolved": "https://registry.npmjs.org/@svgr/core/-/core-8.1.0.tgz",
"integrity": "sha512-8QqtOQT5ACVlmsvKOJNEaWmRPmcojMOzCz4Hs2BGG/toAp/K38LcsMRyLp349glq5AzJbCEeimEoxaX6v/fLrA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/core": "^7.21.3",
"@svgr/babel-preset": "8.1.0",
@@ -6855,6 +6866,7 @@
"integrity": "sha512-WezcBo8a0Dg2rnR82zhwoR6aRNxeTGfK5QCD6TQ+kg3xx/zNT02s/0o+81h/3zhvFSB24NtqEr8FTw88O5W/JQ==",
"hasInstallScript": true,
"license": "Apache-2.0",
+ "peer": true,
"dependencies": {
"@swc/counter": "^0.1.3",
"@swc/types": "^0.1.24"
@@ -7544,6 +7556,7 @@
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.2.tgz",
"integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"csstype": "^3.0.2"
}
@@ -7903,6 +7916,7 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"license": "MIT",
+ "peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -7988,6 +8002,7 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
@@ -8033,6 +8048,7 @@
"resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.40.0.tgz",
"integrity": "sha512-a9aIL2E3Z7uYUPMCmjMFFd5MWhn+ccTubEvnMy7rOTZCB62dXBJtz0R5BZ/TPuX3R9ocBsgWuAbGWQ+Ph4Fmlg==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@algolia/abtesting": "1.6.0",
"@algolia/client-abtesting": "5.40.0",
@@ -8544,6 +8560,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.8.9",
"caniuse-lite": "^1.0.30001746",
@@ -9576,6 +9593,7 @@
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz",
"integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
@@ -11144,6 +11162,7 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -16317,6 +16336,7 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -16997,6 +17017,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@@ -17900,6 +17921,7 @@
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz",
"integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"cssesc": "^3.0.0",
"util-deprecate": "^1.0.2"
@@ -18736,6 +18758,7 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=0.10.0"
}
@@ -18745,6 +18768,7 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"scheduler": "^0.27.0"
},
@@ -18800,6 +18824,7 @@
"resolved": "https://registry.npmjs.org/@docusaurus/react-loadable/-/react-loadable-6.0.0.tgz",
"integrity": "sha512-YMMxTUQV/QFSnbgrP3tjDzLHRg7vsbMn8e9HAa8o/1iXoiomo48b7sk/kkmWEuWNDPJVlKSJRB6Y2fHqdJk+SQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/react": "*"
},
@@ -18828,6 +18853,7 @@
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.4.tgz",
"integrity": "sha512-Ys9K+ppnJah3QuaRiLxk+jDWOR1MekYQrlytiXxC1RyfbdsZkS5pvKAzCCr031xHixZwpnsYNT5xysdFHQaYsA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/runtime": "^7.12.13",
"history": "^4.9.0",
@@ -19625,6 +19651,7 @@
"resolved": "https://registry.npmjs.org/sass/-/sass-1.93.2.tgz",
"integrity": "sha512-t+YPtOQHpGW1QWsh1CHQ5cPIr9lbbGZLZnbihP/D/qZj/yuV68m8qarcV17nvkOX81BCrvzAlq2klCQFZghyTg==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"chokidar": "^4.0.0",
"immutable": "^5.0.2",
@@ -20937,7 +20964,8 @@
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
- "license": "0BSD"
+ "license": "0BSD",
+ "peer": true
},
"node_modules/type-fest": {
"version": "2.19.0",
@@ -21000,6 +21028,7 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"devOptional": true,
"license": "Apache-2.0",
+ "peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -21036,6 +21065,7 @@
"integrity": "sha512-Wj7/AMtE9MRnAXa6Su3Lk0LNCfqDYgfwVjwRFVum9U7wsto1imuHqk4kTm7Jni+5A0Hn7dttL6O/zjvUvoo+8A==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"defu": "^6.1.4",
"exsolve": "^1.0.7",
@@ -21415,6 +21445,7 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -21636,6 +21667,7 @@
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.102.1.tgz",
"integrity": "sha512-7h/weGm9d/ywQ6qzJ+Xy+r9n/3qgp/thalBbpOi5i223dPXKi04IBtqPN9nTd+jBc7QKfvDbaBnFipYp4sJAUQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/eslint-scope": "^3.7.7",
"@types/estree": "^1.0.8",
@@ -22063,6 +22095,7 @@
"dev": true,
"hasInstallScript": true,
"license": "Apache-2.0",
+ "peer": true,
"bin": {
"workerd": "bin/workerd"
},
@@ -22329,6 +22362,7 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
"license": "MIT",
+ "peer": true,
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}