diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..5aea5e4c32 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +content/* @prisma/dev-advocates-write diff --git a/.github/workflows/lost-pixel.yml b/.github/workflows/lost-pixel.yml index 1f859a3d5d..325ba8eea0 100644 --- a/.github/workflows/lost-pixel.yml +++ b/.github/workflows/lost-pixel.yml @@ -1,3 +1,4 @@ +--- name: LostPixel on: [push] @@ -17,8 +18,7 @@ jobs: id: gatsby-cache-build uses: actions/cache@v2 with: - path: | - public + path: public .cache key: ${{ runner.os }}-gatsby-build-${{ github.run_id }} restore-keys: | diff --git a/.github/workflows/notion.yml b/.github/workflows/notion.yml index 44655e5f3a..7090581aed 100644 --- a/.github/workflows/notion.yml +++ b/.github/workflows/notion.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: inputs: setup: - description: 'Populate your notion database with all the requried properties' + description: 'Populate your notion database with all the required properties' type: boolean syncIssues: description: 'sync all other existing issues in this repo' diff --git a/cSpell.json b/cSpell.json index f63b541815..4bf3df6f3f 100644 --- a/cSpell.json +++ b/cSpell.json @@ -73,7 +73,8 @@ "Rallly", "Dundring", "Letterpad", - "Hitori" + "Hitori", + "Zenstack" ], "ignoreWords": [ "Ania", @@ -92,7 +93,8 @@ "Distroless", "Nikolas", "Supavisor", - "inshellisense" + "inshellisense", + "janedoe" ], "patterns": [ { diff --git a/config.ts b/config.ts index c02c94a7c5..c74dd432c7 100644 --- a/config.ts +++ b/config.ts @@ -35,6 +35,7 @@ const siteConfig = { type: 'bucket', bucketName: '/300-accelerate', hidden: false, + includeSideNav: '/500-platform', }, { text: 'Pulse', @@ -42,13 +43,14 @@ const siteConfig = { type: 'bucket', bucketName: '/400-pulse', hidden: false, + includeSideNav: '/500-platform', }, { text: 'Platform', to: '/platform', type: 'bucket', bucketName: '/500-platform', - hidden: false, + hidden: true, }, { text: 'About', @@ -89,7 +91,7 @@ const siteConfig = { }, ORMPlatformLinkData: { porm: { - title: 'Prisma ORM', + title: 'Build with Prisma ORM', icon: 'database', description: 'Open source Node.js and TypeScript ORM with an intuitive data model, automated migrations, type-safety, and auto-completion.', @@ -106,10 +108,10 @@ const siteConfig = { ], }, pdp: { - title: 'Prisma Data Platform', + title: 'Grow as your app evolves', icon: 'triangle', description: - 'An ecosystem of tools empowering teams to build data-heavy, global-first applications.', + 'Expand your application capabilities with global database caching, connection pooling and real-time database events.', links: [ { url: 'accelerate', @@ -124,7 +126,7 @@ const siteConfig = { }, GeneralLinkData: [ { - title: `What is Prisma`, + title: `What is Prisma ORM`, description: 'An overview of what Prisma ORM is and how it works.', url: 'orm/overview/introduction/what-is-prisma', icon: 'fa-regular fa-question', @@ -136,9 +138,9 @@ const siteConfig = { icon: 'fa-solid fa-arrow-right-arrow-left', }, { - title: `Prisma in your stack`, + title: `Prisma ORM in your stack`, description: - 'Use Prisma to build a GraphQL or REST API, or as part of a fullstack application.', + 'Use Prisma ORM to build a GraphQL or REST API, or as part of a fullstack application.', url: 'orm/overview/prisma-in-your-stack', icon: 'fa-solid fa-server', }, @@ -149,8 +151,8 @@ const siteConfig = { icon: 'fa-solid fa-eye', }, { - title: `Adopting Prisma`, - description: 'Migrate to Prisma from other ORMs.', + title: `Adopting Prisma ORM`, + description: 'Migrate to Prisma ORM from other ORMs.', url: 'orm/more/migrating-to-prisma', icon: 'fa-solid fa-download', }, @@ -163,31 +165,39 @@ const siteConfig = { }, ], CommunityLinksData: [ + // { + // id: 'slack', + // title: 'Slack', + // description: 'Engage with a vibrant community of developers and companies adopting Prisma', + // icon: 'fa-brands fa-slack', + // link: 'https://slack.prisma.io/', + // linkText: 'Join our channel', + // }, { - id: 'slack', - title: 'Slack', - description: 'Engage with a vibrant community of developers and companies adopting Prisma', - icon: 'fa-brands fa-slack', - link: 'https://slack.prisma.io/', - linkText: 'Join our channel', + id: 'discord', + title: 'Discord', + description: + 'Chat in real-time, hang out, and share ideas with community members and our team.', + icon: 'fa-brands fa-discord', + link: 'https://pris.ly/discord', + linkText: 'Join our server', }, { id: 'github', title: 'GitHub', description: - 'Browse the Prisma source code, send feedback, or join the discussion on GitHub.', + 'Browse the Prisma ORM source code, send feedback, or join the discussion on GitHub.', icon: 'fa-brands fa-github', link: 'https://github.com/prisma', linkText: 'Contribute in GitHub', }, { - id: 'discord', - title: 'Discord', - description: - 'Chat in real-time, hang out, and share ideas with community members and our team.', - icon: 'fa-brands fa-discord', - link: 'https://pris.ly/discord', - linkText: 'Join our server', + id: 'X', + title: 'X', + description: 'Stay up-to-date, join the discussion, and connect with the community on X.', + icon: 'fa-brands fa-x-twitter', + link: 'https://twitter.com/prisma', + linkText: 'Follow us on X', }, ], CardLinks: { @@ -264,6 +274,7 @@ const siteConfig = { footer: { newsletter: { text: 'Stay up to date with the latest features and changes to Prisma', + GATSBY_BREVO_API_KEY: process.env.GATSBY_BREVO_API_KEY || '', }, }, } diff --git a/content/100-getting-started/01-quickstart.mdx b/content/100-getting-started/01-quickstart.mdx index 440faaa0b3..15939eaf28 100644 --- a/content/100-getting-started/01-quickstart.mdx +++ b/content/100-getting-started/01-quickstart.mdx @@ -2,18 +2,18 @@ title: 'Quickstart' duration: '5 min' metaTitle: 'Quickstart with TypeScript & SQLite' -metaDescription: 'Get started with Prisma in 5 minutes. You will learn how to send queries to a SQLite database in a plain TypeScript script using Prisma Client.' +metaDescription: 'Get started with Prisma ORM in 5 minutes. You will learn how to send queries to a SQLite database in a plain TypeScript script using Prisma Client.' search: true --- -In this Quickstart guide, you'll learn how to get started with Prisma from scratch using a plain **TypeScript** project and a local **SQLite** database file. It covers **data modeling**, **migrations** and **querying** a database. +In this Quickstart guide, you'll learn how to get started with Prisma ORM from scratch using a plain **TypeScript** project and a local **SQLite** database file. It covers **data modeling**, **migrations** and **querying** a database. -If you want to use Prisma with your own PostgreSQL, MySQL, MongoDB or any other supported database, go here instead: +If you want to use Prisma ORM with your own PostgreSQL, MySQL, MongoDB or any other supported database, go here instead: -- [Start with Prisma from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql) -- [Add Prisma to an existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql) +- [Start with Prisma ORM from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql) +- [Add Prisma ORM to an existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql) @@ -21,7 +21,7 @@ If you want to use Prisma with your own PostgreSQL, MySQL, MongoDB or any other You need Node.js v16.13.0 or higher for this guide (learn more about [system requirements](/orm/reference/system-requirements)). -## 1. Create TypeScript project and set up Prisma +## 1. Create TypeScript project and set up Prisma ORM As a first step, create a project directory and navigate into it: @@ -57,7 +57,7 @@ Then, install the Prisma CLI as a development dependency in the project: npm install prisma --save-dev ``` -Finally, set up Prisma with the `init` command of the Prisma CLI: +Finally, set up Prisma ORM with the `init` command of the Prisma CLI: ```terminal npx prisma init --datasource-provider sqlite @@ -253,7 +253,7 @@ npx ts-node script.ts Notice how the single `User` object is now enclosed with square brackets in the console. That's because the `findMany` returned an array with a single object inside. -### 4.3. Explore relation queries with Prisma +### 4.3. Explore relation queries with Prisma Client One of the main features of Prisma Client is the ease of working with [relations](/orm/prisma-schema/data-model/relations). In this section, you'll learn how to create a `User` and a `Post` record in a nested write query. Afterwards, you'll see how you can retrieve the relation from the database using the `include` option. @@ -312,7 +312,7 @@ npx ts-node script.ts -By default, Prisma only returns _scalar_ fields in the result objects of a query. That's why, even though you also created a new `Post` record for the new `User` record, the console only printed an object with three scalar fields: `id`, `email` and `name`. +By default, Prisma Client only returns _scalar_ fields in the result objects of a query. That's why, even though you also created a new `Post` record for the new `User` record, the console only printed an object with three scalar fields: `id`, `email` and `name`. In order to also retrieve the `Post` records that belong to a `User`, you can use the `include` option via the `posts` relation field: @@ -385,30 +385,30 @@ Notice that the objects in the `usersWithPosts` array are fully typed as well. T ## 5. Next steps -In this Quickstart guide, you have learned how to get started with Prisma in a plain TypeScript project. Feel free to explore the Prisma Client API a bit more on your own, e.g. by including filtering, sorting, and pagination options in the `findMany` query or exploring more operations like `update` and `delete` queries. +In this Quickstart guide, you have learned how to get started with Prisma ORM in a plain TypeScript project. Feel free to explore the Prisma Client API a bit more on your own, e.g. by including filtering, sorting, and pagination options in the `findMany` query or exploring more operations like `update` and `delete` queries. ### Explore the data in Prisma Studio -Prisma comes with a built-in GUI to view and edit the data in your database. You can open it using the following command: +Prisma ORM comes with a built-in GUI to view and edit the data in your database. You can open it using the following command: ```terminal npx prisma studio ``` -### Set up Prisma with your own database +### Set up Prisma ORM with your own database -If you want to move forward with Prisma using your own PostgreSQL, MySQL, MongoDB or any other supported database, follow the Set Up Prisma guides: +If you want to move forward with Prisma ORM using your own PostgreSQL, MySQL, MongoDB or any other supported database, follow the Set Up Prisma ORM guides: -- [Start with Prisma from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql) -- [Add Prisma to an existing project](/getting-started/setup-prisma/add-to-existing-project) +- [Start with Prisma ORM from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql) +- [Add Prisma ORM to an existing project](/getting-started/setup-prisma/add-to-existing-project) -### Explore ready-to-run Prisma examples +### Explore ready-to-run Prisma ORM examples -Check out the [`prisma-examples`](https://github.com/prisma/prisma-examples/) repository on GitHub to see how Prisma can be used with your favorite library. The repo contains examples with Express, NestJS, GraphQL as well as fullstack examples with Next.js and Vue.js, and a lot more. +Check out the [`prisma-examples`](https://github.com/prisma/prisma-examples/) repository on GitHub to see how Prisma ORM can be used with your favorite library. The repo contains examples with Express, NestJS, GraphQL as well as fullstack examples with Next.js and Vue.js, and a lot more. -### Build an app with Prisma +### Build an app with Prisma ORM -The Prisma blog features comprehensive tutorials about Prisma, check out our latest ones: +The Prisma blog features comprehensive tutorials about Prisma ORM, check out our latest ones: - [Build a fullstack app with Remix](https://www.prisma.io/blog/fullstack-remix-prisma-mongodb-1-7D0BfTXBmB6r) (5 parts, including videos) - [Build a REST API with NestJS](https://www.prisma.io/blog/nestjs-prisma-rest-api-7D056s1BmOL0) diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx index 21ddb6ed77..e2f7b0fe20 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/100-connect-your-database.mdx @@ -142,7 +142,7 @@ datasource db { } ``` -You will also need to [set the relation mode type to `prisma`](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: +You will also need to set the relation mode type to `prisma` in order to [emulate foreign key constraints](/orm/overview/databases/planetscale#option-1-emulate-relations-in-prisma-client) in the `datasource` block: ```prisma file=schema.prisma highlight=4;add datasource db { @@ -152,6 +152,8 @@ datasource db { } ``` +> **Note**: Since February 2024, you can alternatively [use foreign key constraints on a database-level in PlanetScale](/orm/overview/databases/planetscale#option-2-enable-foreign-key-constraints-in-the-planetscale-database-settings), which omits the need for setting `relationMode = "prisma"`. + The `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx index 734bfeee23..fcc8b432ca 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/150-using-prisma-migrate.mdx @@ -11,7 +11,7 @@ toc: false -In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your [Prisma schema](/orm/prisma-schema) in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following data model to your [Prisma schema](/orm/prisma-schema) in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -60,7 +60,7 @@ Great, you now created three tables in your database with Prisma Migrate 🚀 -In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -109,7 +109,7 @@ Great, you now created three tables in your database with Prisma Migrate 🚀 -In this guide, you'll use Prisma's [`db push` command](/orm/prisma-migrate/workflows/prototyping-your-schema) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use Prisma's [`db push` command](/orm/prisma-migrate/workflows/prototyping-your-schema) to create the tables in your database. Add the following data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -157,7 +157,7 @@ Great, you now created three tables in your database with Prisma's `db push` com -In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { @@ -533,7 +533,7 @@ END CATCH -In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`: +In this guide, you'll use [Prisma Migrate](/orm/prisma-migrate) to create the tables in your database. Add the following data model to your Prisma schema in `prisma/schema.prisma`: ```prisma file=prisma/schema.prisma copy model Post { diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx index dc0d133e74..41d3ef2c46 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/300-next-steps.mdx @@ -9,7 +9,7 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma ORM. ### Continue exploring the Prisma Client API @@ -73,7 +73,7 @@ const deletedUser = await prisma.user.delete({ Prisma Studio is a visual editor for the data in your database. Run `npx prisma studio` in your terminal. -### Try a Prisma example +### Try a Prisma ORM example The [`prisma-examples`](https://github.com/prisma/prisma-examples/) repository contains a number of ready-to-run examples: diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx index c8cb90bda0..b6761c67f5 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/110-relational-databases/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['postgresql', 'mysql', 'sqlserver', 'planetscale', 'cockroachdb'] -Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). +Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma ORM to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). @@ -63,7 +63,7 @@ This tutorial will also assume that you can push to the `main` branch of your da > See [System requirements](/orm/reference/system-requirements) for exact version requirements. -Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma ORM, check out the [Quickstart](/getting-started/quickstart). ## Create project setup @@ -118,7 +118,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: +Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: ```terminal copy npx prisma init diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx index 628f0abc58..b6a1f1afbf 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/300-next-steps.mdx @@ -9,7 +9,7 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma ORM. ### Continue exploring the Prisma Client API diff --git a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx index d85b9fab97..bf36122cbe 100644 --- a/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/100-start-from-scratch/120-mongodb/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['mongodb'] -Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma to your MongoDB database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli) and [Prisma Client](/orm/prisma-client). +Learn how to create a new Node.js or TypeScript project from scratch by connecting Prisma ORM to your MongoDB database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli) and [Prisma Client](/orm/prisma-client). @@ -27,7 +27,7 @@ In order to successfully complete this guide, you need: -Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) at hand. If you don't have a database server running and just want to explore Prisma ORM, check out the [Quickstart](/getting-started/quickstart). > See [System requirements](/orm/reference/system-requirements) for exact version requirements. @@ -78,7 +78,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: +Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command: ```terminal copy npx prisma init diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx index d1079ba7ce..3dc099358c 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/100-connect-your-database.mdx @@ -127,7 +127,7 @@ datasource db { } ``` -You will also need to [set the relation mode type to `prisma`](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) in the `datasource` block: +You will also need to set the relation mode type to `prisma` in order to [emulate foreign key constraints](/orm/overview/databases/planetscale#option-1-emulate-relations-in-prisma-client) in the `datasource` block: ```prisma file=schema.prisma highlight=4;add datasource db { @@ -137,6 +137,8 @@ datasource db { } ``` +> **Note**: Since February 2024, you can alternatively [use foreign key constraints on a database-level in PlanetScale](/orm/overview/databases/planetscale#option-2-enable-foreign-key-constraints-in-the-planetscale-database-settings), which omits the need for setting `relationMode = "prisma"`. + The `url` is [set via an environment variable](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) which is defined in `.env`: ```bash file=.env diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx index 860789a46b..35279526d0 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/150-introspection.mdx @@ -7,7 +7,7 @@ dbSwitcher: ['postgresql', 'mysql', 'sqlserver', 'planetscale', 'cockroachdb'] toc: false --- -## Introspect your database with Prisma +## Introspect your database with Prisma ORM @@ -349,11 +349,11 @@ Run the following command to introspect your database: npx prisma db pull ``` -This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model. +This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in your Prisma schema. After the introspection is complete, your Prisma schema file was updated: -![Introspect your database with Prisma](../../../../doc-images/prisma-db-pull-generate-schema.png) +![Introspect your database with Prisma ORM](../../../../doc-images/prisma-db-pull-generate-schema.png) The data model now looks similar to this (note that the fields on the models have been reordered for better readability): @@ -384,7 +384,7 @@ model User { } ``` -Prisma's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. +Prisma ORM's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. Right now, there's a few minor "issues" with the data model: @@ -423,7 +423,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma ORM models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -490,7 +490,7 @@ Run the following command to introspect your database: npx prisma db pull ``` -This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model. +This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in the Prisma schema. After the introspection is complete, your Prisma schema file was updated: @@ -533,7 +533,7 @@ Refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference) f -Prisma's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. +Prisma ORM's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. Right now, there's a few minor "issues" with the data model: @@ -574,7 +574,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma ORM models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. Sometimes though, you may want to make additional changes to the names of the columns and tables that are exposed in the Prisma Client API. A common example is to translate _snake_case_ notation which is often used in database schemas into _PascalCase_ and _camelCase_ notations which feel more natural for JavaScript/TypeScript developers. @@ -636,7 +636,7 @@ Run the following command to introspect your database: npx prisma db pull ``` -This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model. +This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in the Prisma schema. After the introspection is complete, your Prisma schema file was updated: @@ -710,7 +710,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma ORM models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -777,7 +777,7 @@ Run the following command to introspect your database: npx prisma db pull ``` -This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model. +This commands reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in the Prisma schema. After the introspection is complete, your Prisma schema file was updated: @@ -865,7 +865,7 @@ Prisma Migrate will now keep the manually added relation fields. Because relation fields are _virtual_ (i.e. they _do not directly manifest in the database_), you can manually rename them in your Prisma schema without touching the database. -In this example, the database schema follows the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models. This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema follows the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma ORM models. This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names @@ -932,11 +932,11 @@ Run the following command to introspect your database: npx prisma db pull ``` -This commands reads the environment variable used to define the `url` in your `schema.prisma`, `DATABASE_URL`, that in our case is set in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model. +This commands reads the environment variable used to define the `url` in your `schema.prisma`, `DATABASE_URL`, that in our case is set in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in the Prisma schema. After the introspection is complete, your Prisma schema file was updated: -![Introspect your database with Prisma](../../../../doc-images/prisma-db-pull-generate-schema.png) +![Introspect your database with Prisma ORM](../../../../doc-images/prisma-db-pull-generate-schema.png) The data model now looks similar to this: @@ -967,7 +967,7 @@ model User { } ``` -Prisma's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. +Prisma ORM's data model is a declarative representation of your database schema and serves as the foundation for the generated Prisma Client library. Your Prisma Client instance will expose queries that are _tailored_ to these models. Right now, there's a few minor "issues" with the data model: @@ -1006,7 +1006,7 @@ model User { } ``` -In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API. +In this example, the database schema did follow the [naming conventions](/orm/reference/prisma-schema-reference#naming-conventions) for Prisma ORM models (only the virtual relation fields that were generated from introspection did not adhere to them and needed adjustment). This optimizes the ergonomics of the generated Prisma Client API.
Using custom model and field names diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx index 4a2c944b59..b7648593bc 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/300-next-steps.mdx @@ -9,7 +9,7 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma ORM. ### Continue exploring the Prisma Client API @@ -87,7 +87,7 @@ To evolve the app, you need to follow the same flow of the tutorial: ![Introspect workflow](../../../images/prisma-evolve-app-workflow.png) -### Try a Prisma example +### Try a Prisma ORM example The [`prisma-examples`](https://github.com/prisma/prisma-examples/) repository contains a number of ready-to-run examples: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx index 7ab09823a1..15847b80a3 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['postgresql', 'mysql', 'sqlserver', 'planetscale', 'cockroachdb'] -Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). +Learn how to add Prisma ORM to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). @@ -18,7 +18,7 @@ Learn how to add Prisma to an existing Node.js or TypeScript project by connecti
-If you're migrating to Prisma from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides. +If you're migrating to Prisma ORM from another ORM, see our [Migrate from TypeORM](/orm/more/migrating-to-prisma/migrate-from-typeorm) or [Migrate from Sequelize](/orm/more/migrating-to-prisma/migrate-from-sequelize) migration guides.
@@ -70,9 +70,9 @@ In order to successfully complete this guide, you need: > See [System requirements](/orm/reference/system-requirements) for exact version requirements. -Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma ORM, check out the [Quickstart](/getting-started/quickstart). -## Set up Prisma +## Set up Prisma ORM As a first step, navigate into your project directory that contains the `package.json` file. @@ -90,11 +90,11 @@ npx prisma -See [installation instructions](/orm/tools/prisma-cli#installation) to learn how to install Prisma using a different package manager. +See [installation instructions](/orm/tools/prisma-cli#installation) to learn how to install Prisma ORM using a different package manager. -Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: +Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: ```terminal copy npx prisma init diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx index 2b5d5fa1c9..9472d84e5e 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/125-introspection.mdx @@ -9,9 +9,9 @@ toc: false # Introspection -Prisma introspects a MongoDB schema by sampling the data stored in the given database and inferring the schema of that data. +Prisma ORM introspects a MongoDB schema by sampling the data stored in the given database and inferring the schema of that data. -For the purposes of illustrating introspection, this guide will help you setup a MongoDB from scratch. But if you have a MongoDB database already, feel free to jump to [Initializing Prisma](#initializing-prisma) in your project. +For the purposes of illustrating introspection, this guide will help you setup a MongoDB from scratch. But if you have a MongoDB database already, feel free to jump to [Initializing Prisma ORM](#initializing-prisma-orm) in your project. ## Setting up your Database @@ -27,9 +27,9 @@ Next, add some posts to our `Post` collection. It's important that the ObjectID ![Create some posts within the Post collection](./3-create-posts.jpg) -## Initializing Prisma +## Initializing Prisma ORM -Now that you have a MongoDB database, the next step is to create a new project and initialize Prisma: +Now that you have a MongoDB database, the next step is to create a new project and initialize Prisma ORM: ```terminal copy mkdir blog @@ -39,7 +39,7 @@ npm install -D prisma npx prisma init ``` -Initializing Prisma will create a `prisma/schema.prisma` file. Edit this file to use MongoDB: +Initializing Prisma ORM will create a `prisma/schema.prisma` file. Edit this file to use MongoDB: ```prisma file=prisma/schema.prisma datasource db { @@ -54,7 +54,7 @@ generator client { Next you'll need to adjust your `.env` file to point the `DATABASE_URL` to your MongoDB database -## Introspecting MongoDB with Prisma +## Introspecting MongoDB with Prisma ORM You're now ready to introspect. Run the following command to introspect your database: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx index 628f0abc58..a83c897122 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/300-next-steps.mdx @@ -9,7 +9,7 @@ toc: false ## Next steps -This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma. +This section lists a number of potential next steps you can now take from here. Feel free to explore these or read the [Introduction](/orm/overview/introduction/what-is-prisma) page to get a high-level overview of Prisma ORM. ### Continue exploring the Prisma Client API @@ -75,7 +75,7 @@ const deletedUser = await prisma.user.delete({ Prisma Studio is a visual editor for the data in your database. Run `npx prisma studio` in your terminal. -### Try a Prisma example +### Try a Prisma ORM example The [`prisma-examples`](https://github.com/prisma/prisma-examples/) repository contains a number of ready-to-run examples: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx index d88211470b..8a7a155ff5 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/index.mdx @@ -10,7 +10,7 @@ dbSwitcher: ['mongodb'] -Learn how to add Prisma to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). +Learn how to add Prisma ORM to an existing Node.js or TypeScript project by connecting it to your database and generating a Prisma Client for database access. The following tutorial introduces you to [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Introspection](/orm/prisma-schema/introspection). @@ -18,7 +18,7 @@ Learn how to add Prisma to an existing Node.js or TypeScript project by connecti
-If you're migrating to Prisma from Mongoose, see our [Migrate from Mongoose guide](/orm/more/migrating-to-prisma/migrate-from-mongoose). +If you're migrating to Prisma ORM from Mongoose, see our [Migrate from Mongoose guide](/orm/more/migrating-to-prisma/migrate-from-mongoose).
@@ -36,11 +36,11 @@ In order to successfully complete this guide, you need: -Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma, check out the [Quickstart](/getting-started/quickstart). +Make sure you have your database [connection URL](/orm/reference/connection-urls) (that includes your authentication credentials) at hand! If you don't have a database server running and just want to explore Prisma ORM, check out the [Quickstart](/getting-started/quickstart). > See [System requirements](/orm/reference/system-requirements) for exact version requirements. -## Set up Prisma +## Set up Prisma ORM As a first step, navigate into it your project directory that contains the `package.json` file. @@ -56,7 +56,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`: npx prisma ``` -Next, set up your Prisma project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: +Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file template with the following command: ```terminal copy npx prisma init diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/index.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/index.mdx index cd8dc40bca..791ece2e24 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/index.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/index.mdx @@ -7,7 +7,7 @@ toc: false -Include Prisma in an existing project with the following documentation, which explains some core concepts as it guides you through integrating Prisma into your workflow. +Include Prisma ORM in an existing project with the following documentation, which explains some core concepts as it guides you through integrating Prisma ORM into your workflow. diff --git a/content/100-getting-started/02-setup-prisma/index.mdx b/content/100-getting-started/02-setup-prisma/index.mdx index a5b8be18e0..37748d1816 100644 --- a/content/100-getting-started/02-setup-prisma/index.mdx +++ b/content/100-getting-started/02-setup-prisma/index.mdx @@ -1,14 +1,14 @@ --- -title: 'Set up Prisma' -metaTitle: '' -metaDescription: '' +title: 'Set up Prisma ORM' +metaTitle: 'Set up Prisma ORM' +metaDescription: 'Get started with Prisma ORM and your favorite database. Learn about data modeling, migrations and querying.' toc: false staticLink: true --- -Start from scratch or add Prisma to an existing project. The following tutorials introduce you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). +Start from scratch or add Prisma ORM to an existing project. The following tutorials introduce you to the [Prisma CLI](/orm/tools/prisma-cli), [Prisma Client](/orm/prisma-client), and [Prisma Migrate](/orm/prisma-migrate). diff --git a/content/100-getting-started/index.mdx b/content/100-getting-started/index.mdx index a017932ef8..097a3cb937 100644 --- a/content/100-getting-started/index.mdx +++ b/content/100-getting-started/index.mdx @@ -1,108 +1,169 @@ --- -title: 'Get started' -metaTitle: 'Get started' -metaDescription: 'Get started' +title: 'Get Started' +metaTitle: 'Get started with Prisma' +metaDescription: 'Build data-driven applications with ease using Prisma ORM, add connection pooling or global caching with Prisma Accelerate or subscribe to database changes in real-time with Prisma Pulse.' +hideTitle: true +tocDepth: 1 --- -Welcome to the Prisma getting started section! 👋 + -Explore our range of products defined to make working with data easy: +Get started -[**Prisma ORM**](/orm/overview/introduction/what-is-prisma) is an [open source](https://github.com/prisma/prisma) next-generation Node.js and TypeScript ORM that unlocks a new level of developer experience when working with databases thanks to its intuitive data model, automated migrations, type-safety & auto-completion. +Welcome 👋 -[**Prisma Accelerate**](/accelerate/what-is-accelerate) is a global database cache with scalable connection pooling. +Explore our products that make it easy to build and scale data-driven applications: -[**Prisma Pulse**](/pulse/what-is-pulse) allows you to build reactive, real-time applications in a type-safe manner. +[**Prisma ORM**](/orm/overview/introduction/what-is-prisma) is a next-generation Node.js and TypeScript ORM that unlocks a new level of developer experience when working with databases thanks to its intuitive data model, automated migrations, type-safety & auto-completion. - - -## Which tutorial is right for me? - -### Get started with Prisma ORM - -To get up and running with Prisma in your local environment, follow our Quickstart guide It makes no assumptions about your knowledge level and offers the **fastest** way from install to query! - - - Quickstart - - -If you're looking to incorporate Prisma with an **existing project**, choose whether you want to use a SQL database or MongoDB. - - - Existing SQL project - - - - Existing MongoDB project - - -To learn how to **create a new project** with Prisma from scratch, choose between SQL and MongoDB. Both tutorials will guide you through creating a project, connecting your database, and querying your data. - - - New SQL project - - - - New MongoDB project - +[**Prisma Accelerate**](/accelerate/what-is-accelerate) is a global database cache with scalable connection pooling. -If you're interested in learning how Prisma integrates with your favorite library or framework, such as Next.js, Express, Apollo GraphQL, NestJS, etc, you can check out our **ready-to-run examples**. +[**Prisma Pulse**](/pulse/what-is-pulse) allows you to build reactive, real-time applications in a type-safe manner. - - Examples - + -### Get started with Prisma Accelerate - -Add **Accelerate** to your app to use connection pooling and global database caching. - - - Get started with Accelerate - - -### Get started with Prisma Pulse - -Add **Pulse** to your app to subscribe to real-time updates from your database using Prisma Client. - - - Get started with Pulse - - -## Prisma with different tooling - -Prisma can be used with a wide range of tooling and frameworks, the following links outline how to get started with some of them: - -- [Prisma with Next.js](https://www.prisma.io/nextjs) -- [Prisma with GraphQL](https://www.prisma.io/graphql) -- [Prisma with Apollo](https://www.prisma.io/apollo) -- [Prisma with Nestjs](https://www.prisma.io/nestjs) -- [Prisma with Express](https://www.prisma.io/express) -- [Prisma with hapi](https://www.prisma.io/hapi) - - - -Join our thriving community on [Slack](https://slack.prisma.io/), [Discord](https://discord.gg/KQyTW2H5ca), and [GitHub](https://github.com/prisma/prisma) for help and ideas. + - +## Prisma ORM + +Add Prisma ORM to your application in a few minutes to start modeling your data, run schema migrations and query your database. + +### Explore quickly with a SQLite database + +_These options don't require you to have your own database running._ + + + + + + +### Choose an option to get started with your own database + +_Select one of these options if you want to connect Prisma ORM to your own database._ + + + + +

+ Set up Prisma ORM from scratch with your favorite database and + learn basic workflows like data modeling, querying, and migrations. +

+ + } + tech="Postgres SQL" + /> + } + tech="MySQL" + /> + } + tech="SQLServer" + /> + } + tech="PlanetScale" + /> + } + tech="Cockroach DB" + /> + } + tech="Mongo DB" + /> + +
+
+ + +

+ Get started with Prisma ORM and your existing database by + introspecting your database schema and learn how to query your database. +

+ + } + tech="Postgres SQL" + /> + } + tech="MySQL" + /> + } + tech="SQL Server" + /> + } + tech="PlanetScale" + /> + } + tech="Cockroach DB" + /> + } + tech="Mongo DB" + /> + +
+
+
+ +## Prisma Accelerate + +Make your app faster by scaling your database connections and caching database results at the edge with Prisma Accelerate. + + + + + + +## Prisma Pulse + +Build real-time applications by subscribing to data changes in your database using Prisma Pulse. + + + + 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 1ce8c749c4..2ea9fcd4da 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 @@ -1,12 +1,12 @@ --- -title: 'What is Prisma?' -metaTitle: 'What is Prisma? (Overview)' -metaDescription: "This page gives a high-level overview of what Prisma is and how it works. It's a great starting point for Prisma newcomers!" +title: 'What is Prisma ORM?' +metaTitle: 'What is Prisma ORM? (Overview)' +metaDescription: "This page gives a high-level overview of what Prisma ORM is and how it works. It's a great starting point for Prisma newcomers!" --- -## What is Prisma? +## What is Prisma ORM? -Prisma is an [open-source](https://github.com/prisma/prisma) next-generation ORM. It consists of the following parts: +Prisma ORM is an [open-source](https://github.com/prisma/prisma) next-generation ORM. It consists of the following parts: - **Prisma Client**: Auto-generated and type-safe query builder for Node.js & TypeScript - **Prisma Migrate**: Migration system @@ -32,11 +32,11 @@ Prisma Client can be used in _any_ Node.js (supported versions) or TypeScript ba > -## How does Prisma work? +## How does Prisma ORM work? ### The Prisma schema -Every project that uses a tool from the Prisma toolkit starts with a [Prisma schema file](/orm/prisma-schema). The Prisma schema allows developers to define their _application models_ in an intuitive data modeling language. It also contains the connection to a database and defines a _generator_: +Every project that uses a tool from the Prisma ORM toolkit starts with a [Prisma schema file](/orm/prisma-schema). The Prisma schema allows developers to define their _application models_ in an intuitive data modeling language. It also contains the connection to a database and defines a _generator_: , ]}> @@ -109,11 +109,11 @@ In this schema, you configure three things: - **Generator**: Indicates that you want to generate Prisma Client - **Data model**: Defines your application models -### The Prisma data model +### 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. -#### Functions of Prisma models +#### Functions of Prisma schema data models The data model is a collection of [models](/orm/prisma-schema/data-model/models#defining-models). A model has two major functions: @@ -237,15 +237,15 @@ const post = await prisma.post.update({ Note that when using TypeScript, the result of this query will be _statically typed_ so that you can't accidentally access a property that doesn't exist (and any typos are caught at compile-time). Learn more about leveraging Prisma Client's generated types on the [Advanced usage of generated types](/orm/prisma-client/type-safety/operating-against-partial-structures-of-model-types) page in the docs. -## Typical Prisma workflows +## Typical Prisma ORM workflows -As mentioned above, there are two ways for "getting" your data model into the Prisma schema. Depending on which approach you choose, your main Prisma workflow might look different. +As mentioned above, there are two ways for "getting" your data model into the Prisma schema. Depending on which approach you choose, your main Prisma ORM workflow might look different. ### Prisma Migrate -With **Prisma Migrate**, Prisma's integrated database migration tool, the workflow looks as follows: +With **Prisma Migrate**, Prisma ORM's integrated database migration tool, the workflow looks as follows: -1. Manually adjust your [Prisma data model](/orm/prisma-schema/data-model/models) +1. Manually adjust your [Prisma schema data model](/orm/prisma-schema/data-model/models) 1. Migrate your development database using the `prisma migrate dev` CLI command 1. Use Prisma Client in your application code to access your database diff --git a/content/200-orm/050-overview/100-introduction/200-why-prisma.mdx b/content/200-orm/050-overview/100-introduction/200-why-prisma.mdx index 2a895d874a..5357f85e34 100644 --- a/content/200-orm/050-overview/100-introduction/200-why-prisma.mdx +++ b/content/200-orm/050-overview/100-introduction/200-why-prisma.mdx @@ -1,22 +1,22 @@ --- -title: 'Why Prisma?' -metaTitle: 'Why Prisma? Comparison with SQL query builders & ORMs' -metaDescription: 'Learn about the motivation for Prisma and how it compares to other Node.js and TypeScript database tools like ORMs and SQL query builders.' +title: 'Why Prisma ORM?' +metaTitle: 'Why Prisma ORM? Comparison with SQL query builders & ORMs' +metaDescription: 'Learn about the motivation for Prisma ORM and how it compares to other Node.js and TypeScript database tools like ORMs and SQL query builders.' --- -On this page, you'll learn about the motivation for Prisma and how it compares to other database tools like ORMs and SQL query builders. +On this page, you'll learn about the motivation for Prisma ORM and how it compares to other database tools like traditional ORMs and SQL query builders. Working with relational databases is a major bottleneck in application development. Debugging SQL queries or complex ORM objects often consume hours of development time. -Prisma makes it easy for developers to reason about their database queries by providing a clean and type-safe API for submitting database queries which returns _plain old JavaScript objects_. +Prisma ORM makes it easy for developers to reason about their database queries by providing a clean and type-safe API for submitting database queries which returns _plain old JavaScript objects_. ## TLDR -Prisma's main goal is to make application developers more productive when working with databases. Here are a few examples of how Prisma achieves this: +Prisma ORM's main goal is to make application developers more productive when working with databases. Here are a few examples of how Prisma ORM achieves this: - **Thinking in objects** instead of mapping relational data - **Queries not classes** to avoid complex model objects @@ -27,9 +27,9 @@ Prisma's main goal is to make application developers more productive when workin - **Less boilerplate** so developers can focus on the important parts of their app - **Auto-completion in code editors** instead of needing to look up documentation -The remaining parts of this page discuss how Prisma compares to existing database tools. +The remaining parts of this page discuss how Prisma ORM compares to existing database tools. -## Problems with SQL, ORMs and other database tools +## Problems with SQL, traditional ORMs and other database tools The main problem with the database tools that currently exist in the Node.js and TypeScript ecosystem is that they require a major tradeoff between _productivity_ and _control_. @@ -49,9 +49,9 @@ A common solution that retains a high level of control and provides better produ The biggest drawback with SQL query builders is that application developers still need to think about their data in terms of SQL. This incurs a cognitive and practical cost of translating relational data into objects. Another issue is that it's too easy to shoot yourself in the foot if you don't know exactly what you're doing in your SQL queries. -### ORMs: Less control, better productivity +### Traditional ORMs: Less control, better productivity -ORMs abstract away from SQL by letting you _define your application models as classes_, these classes are mapped to tables in the database. +Traditional ORMs abstract away from SQL by letting you _define your application models as classes_, these classes are mapped to tables in the database. > "Object relational mappers" (ORMs) exist to bridge the gap between the programmers' friend (the object), and the database's primitive (the relation). The reasons for these differing models are as much cultural as functional: programmers like objects because they encapsulate the state of a single thing in a running program. Databases like relations because they better suit whole-dataset constraints and efficient access patterns for the entire dataset. > @@ -74,9 +74,9 @@ As an example, consider how data is organized and relationships are handled with - **Relational databases**: Data is typically normalized (flat) and uses foreign keys to link across entities. The entities then need to be JOINed to manifest the actual relationships. - **Object-oriented**: Objects can be deeply nested structures where you can traverse relationships simply by using dot notation. -This alludes to one of the major pitfalls with ORMs: While they make it _seem_ that you can simply traverse relationships using familiar dot notation, under the hood the ORM generates SQL JOINs which are expensive and have the potential to drastically slow down your application (one symptom of this is the [n+1 problem](https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping)). +This alludes to one of the major pitfalls with traditional ORMs: While they make it _seem_ that you can simply traverse relationships using familiar dot notation, under the hood the ORM generates SQL JOINs which are expensive and have the potential to drastically slow down your application (one symptom of this is the [n+1 problem](https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping)). -To conclude: The appeal of ORMs is the premise of abstracting away the relational model and thinking about your data purely in terms of objects. While the premise is great, it's based on the wrong assumption that relational data can easily be mapped to objects which leads to lots of complications and pitfalls. +To conclude: The appeal of traditional ORMs is the premise of abstracting away the relational model and thinking about your data purely in terms of objects. While the premise is great, it's based on the wrong assumption that relational data can easily be mapped to objects which leads to lots of complications and pitfalls. ## Application developers should care about data – not SQL @@ -88,8 +88,8 @@ There's another argument to be made against SQL in application development. The Developers should be able to ask for the data they need instead of having to worry about "doing the right thing" in their SQL queries. They should be using an abstraction that makes the right decisions for them. This can mean that the abstraction imposes certain "healthy" constraints that prevent developers from making mistakes. -## Prisma makes developers productive +## Prisma ORM makes developers productive -Prisma's main goal is to make application developers more productive when working with databases. Considering the tradeoff between productivity and control again, this is how Prisma fits in: +Prisma ORM's main goal is to make application developers more productive when working with databases. Considering the tradeoff between productivity and control again, this is how Prisma ORM fits in: -![Prisma makes developers productive](prisma-makes-devs-productive.png) +![Prisma ORM makes developers productive](prisma-makes-devs-productive.png) diff --git a/content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx b/content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx index 060c5fbb2e..684c9d38cc 100644 --- a/content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx +++ b/content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx @@ -1,22 +1,22 @@ --- -title: 'Should you use Prisma?' -metaTitle: 'Should you use Prisma as a Node.js/TypeScript ORM?' -metaDescription: 'Prisma is a new kind of ORM. This page explains when Prisma would be a good fit, and provides alternatives for other scenarios.' +title: 'Should you use Prisma ORM?' +metaTitle: 'Should you use Prisma ORM as a Node.js/TypeScript ORM?' +metaDescription: 'Prisma ORM is a new kind of ORM. This page explains when Prisma ORM would be a good fit, and provides alternatives for other scenarios.' tocDepth: 3 toc: true --- -Prisma is a new kind of ORM that - like any other tool - comes with its own tradeoffs. This page explains when Prisma would be a good fit, and provides alternatives for other scenarios. +Prisma ORM is a new kind of ORM that - like any other tool - comes with its own tradeoffs. This page explains when Prisma ORM would be a good fit, and provides alternatives for other scenarios. -## Prisma likely _is_ a good fit for you if ... +## Prisma ORM likely _is_ a good fit for you if ... ### ... you are building a server-side application that talks to a database -This is the main use case for Prisma. Server-side applications typically are API servers that expose data operations via technologies like REST, GraphQL or gRPC. They are commonly built as microservices or monolithic apps and deployed via long-running servers or serverless functions. Prisma is a great fit for all of these application and deployment models. +This is the main use case for Prisma ORM. Server-side applications typically are API servers that expose data operations via technologies like REST, GraphQL or gRPC. They are commonly built as microservices or monolithic apps and deployed via long-running servers or serverless functions. Prisma ORM is a great fit for all of these application and deployment models. -Refer to the full list of databases (relational, NoSQL, and NewSQL) that Prisma [supports](/orm/reference/supported-databases). +Refer to the full list of databases (relational, NoSQL, and NewSQL) that Prisma ORM [supports](/orm/reference/supported-databases). ### ... you care about productivity and developer experience Productivity and developer experience are core to how we're building our tools. We're looking to build developer-friendly abstractions for tasks that are complex, error-prone and time-consuming when performed manually. -No matter if you're a SQL newcomer or veteran, Prisma will give you a significant productivity boost for the most common database workflows. +No matter if you're a SQL newcomer or veteran, Prisma ORM will give you a significant productivity boost for the most common database workflows. Here are a couple of the guiding principles and general practices we apply when designing and building our tools: -- [make the right thing easy](https://www.jason.af/right-thing-easy-thing/) +- [make the right thing easy](https://git.io/right-thing-easy-thing) - [pit of success](https://blog.codinghorror.com/falling-into-the-pit-of-success/) - offer intelligent autocompletion where possible - build powerful editor extensions (e.g. for [VS Code](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma)) @@ -65,7 +65,7 @@ Here are a couple of the guiding principles and general practices we apply when ### ... you are working in a team -Prisma shines especially when used in collaborative environments. +Prisma ORM shines especially when used in collaborative environments. The declarative [Prisma schema](/orm/prisma-schema) provides an overview of the current state of the database that's easy to understand for everyone. This is a major improvement to traditional workflows where developers have to dig through migration files to understand the current table structure. @@ -75,7 +75,7 @@ The [Prisma Migrate](/orm/prisma-migrate) workflows are designed in a way to cov ### ... you want a tool that holistically covers your database workflows -Prisma is a lot more than "just another ORM". We are building a database toolkit that covers the daily workflows of application developers that interact with databases. A few examples are: +Prisma ORM is a lot more than "just another ORM". We are building a database toolkit that covers the daily workflows of application developers that interact with databases. A few examples are: - querying (with [Prisma Client](/orm/prisma-client)) - data modeling (in the [Prisma schema](/orm/prisma-schema)) @@ -86,11 +86,11 @@ Prisma is a lot more than "just another ORM". We are building a database toolkit ### ... you value type-safety -Prisma is the only _fully_ type-safe ORM in the TypeScript ecosystem. The generated Prisma Client ensures typed query results even for partial queries and relations. You can learn more about this in the [type-safety comparison with TypeORM](/orm/more/comparisons/prisma-and-typeorm#type-safety). +Prisma ORM is the only _fully_ type-safe ORM in the TypeScript ecosystem. The generated Prisma Client ensures typed query results even for partial queries and relations. You can learn more about this in the [type-safety comparison with TypeORM](/orm/more/comparisons/prisma-and-typeorm#type-safety). ### ... you want an ORM with a transparent development process, proper maintenance & support -Development of Prisma's open source tools is happening in the open. Most of it happens directly on GitHub in the main [`prisma/prisma`](https://github.com/prisma/prisma) repo: +Development of Prisma ORM's open source tools is happening in the open. Most of it happens directly on GitHub in the main [`prisma/prisma`](https://github.com/prisma/prisma) repo: - issues and PRs in our repos are triaged and prioritized (usually within 1-2 days) - there is a public [roadmap](https://pris.ly/roadmap) that is kept up to date with our plans @@ -102,15 +102,15 @@ Development of Prisma's open source tools is happening in the open. Most of it h Prisma has a lively [community](https://www.prisma.io/community), which you can find on [Slack](https://slack.prisma.io) and [Discord](https://discord.gg/KQyTW2H5ca). We also regularly host Meetups, conferences and other developer-focused events. Join us! -## Prisma likely is _not_ a good fit for you if ... +## Prisma ORM likely is _not_ a good fit for you if ... ### ... you need _full_ control over all database queries -Prisma is an abstraction. As such, an inherent tradeoff of Prisma is a reduced amount of control in exchange for higher productivity. This means, the [Prisma Client API](/orm/prisma-client) might have less capabilities in some scenarios than you get with plain SQL. +Prisma ORM is an abstraction. As such, an inherent tradeoff of Prisma ORM is a reduced amount of control in exchange for higher productivity. This means, the [Prisma Client API](/orm/prisma-client) might have less capabilities in some scenarios than you get with plain SQL. -If your application has requirements for database queries that Prisma does not provide and the workarounds are too costly, you might be better off with a tool that allows you to exercise full control over your database operations using plain SQL. +If your application has requirements for database queries that Prisma ORM does not provide and the workarounds are too costly, you might be better off with a tool that allows you to exercise full control over your database operations using plain SQL. -> **Note**: If you can work around a certain limitation but still would like to see an improvement in the way how Prisma handles the situation, we encourage you to create a [feature request](https://github.com/prisma/prisma/issues/new?assignees=&labels=&template=feature_request.md&title=) on GitHub so that our Product and Engineering teams can look into it. +> **Note**: If you can work around a certain limitation but still would like to see an improvement in the way how Prisma ORM handles the situation, we encourage you to create a [feature request](https://github.com/prisma/prisma/issues/new?assignees=&labels=&template=feature_request.md&title=) on GitHub so that our Product and Engineering teams can look into it. _Alternatives_: SQL drivers (e.g. [`node-postgres`](https://node-postgres.com/), [`mysql`](https://github.com/mysqljs/mysql#readme), [`sqlite3`](https://github.com/mapbox/node-sqlite3#README), ...) @@ -120,13 +120,13 @@ If you don't want to write any code for your backend and just be able to generat With a BaaS, you can typically configure your data model via a high-level API (e.g. [GraphQL SDL](https://www.prisma.io/blog/graphql-sdl-schema-definition-language-6755bcb9ce51)) or a visual editor. Based on this data model, the BaaS generates a CRUD API and provisions a database for you. With this setup, you typically don't have control over the infrastructure the API server and database are running on. -With Prisma, you are building the backend yourself using Node.js or TypeScript. This means you'll have to do a lot more coding work compared to using a BaaS. The benefit of this approach is that you have full flexibility for building, deploying, scaling and maintaining your backend and are not dependent on 3rd party software for a crucial part of your stack. +With Prisma ORM, you are building the backend yourself using Node.js or TypeScript. This means you'll have to do a lot more coding work compared to using a BaaS. The benefit of this approach is that you have full flexibility for building, deploying, scaling and maintaining your backend and are not dependent on 3rd party software for a crucial part of your stack. _Alternatives_: [AWS AppSync](https://aws.amazon.com/appsync/), [8base](https://www.8base.com/), [Nhost](https://nhost.io/), [Supabase](https://supabase.com/), [Firebase](https://firebase.google.com/), [Amplication](https://amplication.com/) ### ... you want a CRUD GraphQL API without writing any code -While tools like the [`nexus-plugin-prisma`](https://nexusjs.org/docs/plugins/prisma/overview) and [`typegraphql-prisma`](https://github.com/MichalLytek/typegraphql-prisma#readme) allow you to quickly generate CRUD operations for your Prisma models in a GraphQL API, these approaches still require you to set up your GraphQL server manually and do some work to expose GraphQL queries and mutations for the models defined in your Prisma schema. +While tools like the [`nexus-plugin-prisma`](https://nexusjs.org/docs/plugins/prisma/overview) and [`typegraphql-prisma`](https://github.com/MichalLytek/typegraphql-prisma#readme) allow you to quickly generate CRUD operations for your Prisma ORM models in a GraphQL API, these approaches still require you to set up your GraphQL server manually and do some work to expose GraphQL queries and mutations for the models defined in your Prisma schema. If you want to get a GraphQL endpoint for your database out-of-the box, other tools might be better suited for your use case. @@ -134,7 +134,7 @@ _Alternatives_: [Hasura](https://hasura.io/), [Postgraphile](https://www.graphil ### ... you want to use raw, type-safe SQL for querying your database -While Prisma does allow you to [send plain SQL queries](/orm/prisma-client/queries/raw-database-access/raw-queries) to your database, it might not be the best fit if you prefer to work with a SQL-based abstraction that you want to be type-safe. Prisma's main benefit is to provide an abstraction layer that makes you more productive compared to writing SQL. +While Prisma ORM does allow you to [send plain SQL queries](/orm/prisma-client/queries/raw-database-access/raw-queries) to your database, it might not be the best fit if you prefer to work with a SQL-based abstraction that you want to be type-safe. Prisma ORM's main benefit is to provide an abstraction layer that makes you more productive compared to writing SQL. If you're a solo developer that is very comfortable with SQL, and you just want to be sure that your database layer is type-safe, a lower-level TypeScript database library might be better for you. 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 ac5ff0e3a2..465e9fbffa 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 @@ -17,7 +17,7 @@ When modeling data, you typically ask questions like: - What are their main characteristics/properties? - How can they be represented with my technology stack? -## Data modeling without Prisma +## Data modeling without Prisma ORM Data modeling typically needs to happen on (at least) two levels: @@ -175,11 +175,11 @@ The call to `findByPk` creates a SQL statement to retrieve the `User` record tha The resulting `user` object is an instance of Sequelize's `Model` class (because `User` inherits from `Model`). It's not a POJO, but an object that implements additional behavior from Sequelize. -## Data modeling with Prisma +## Data modeling with Prisma ORM -Depending on which parts of Prisma you want to use in your application, the data modeling flow looks slightly different. The following two sections explain the workflows for using [**only Prisma Client**](#using-only-prisma-client) and using [**Prisma Client and Prisma Migrate**](#using-prisma-client-and-prisma-migrate). +Depending on which parts of Prisma ORM you want to use in your application, the data modeling flow looks slightly different. The following two sections explain the workflows for using [**only Prisma Client**](#using-only-prisma-client) and using [**Prisma Client and Prisma Migrate**](#using-prisma-client-and-prisma-migrate). -No matter which approach though, with Prisma you never create application models in your programming language by manually defining classes, interfaces, or structs. Instead, the application models are defined in your [Prisma schema](/orm/prisma-schema): +No matter which approach though, with Prisma ORM you never create application models in your programming language by manually defining classes, interfaces, or structs. Instead, the application models are defined in your [Prisma schema](/orm/prisma-schema): - **Only Prisma Client**: Application models in the Prisma schema are _generated based on the introspection of your database schema_. Data modeling happens primarily on the database-level. - **Prisma Client and Prisma Migrate**: Data modeling happens in the Prisma schema by _manually adding application models_ to it. Prisma Migrate maps these application models to tables in the underlying database (currently only supported for relational databases). diff --git a/content/200-orm/050-overview/100-introduction/index.mdx b/content/200-orm/050-overview/100-introduction/index.mdx index 90a1c1af59..67a90622ca 100644 --- a/content/200-orm/050-overview/100-introduction/index.mdx +++ b/content/200-orm/050-overview/100-introduction/index.mdx @@ -6,11 +6,11 @@ metaDescription: "This section gives a high-level overview of what Prisma is and -This page gives a high-level overview of what Prisma is and how it works. +This page gives a high-level overview of what Prisma ORM is and how it works. If you want to get started with a _practical introduction_ and learn about the Prisma Client API, head over to the [**Getting Started**](/getting-started) documentation. -To learn more about the _motivation_ for Prisma, check out the [**Why Prisma?**](/orm/overview/introduction/why-prisma) page. +To learn more about the _motivation_ for Prisma ORM, check out the [**Why Prisma ORM?**](/orm/overview/introduction/why-prisma) page. 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 cb65d49966..f346c80c83 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 @@ -1,6 +1,6 @@ --- title: 'REST' -metaTitle: 'Building REST APIs with Prisma' +metaTitle: 'Building REST APIs with Prisma ORM' metaDescription: 'This page gives an overview of the most important things when building REST APIs with Prisma. It shows practical examples and the supported libraries.' --- @@ -16,7 +16,7 @@ When building REST APIs, Prisma Client can be used inside your _route controller As Prisma Client is "only" responsible for sending queries to your database, it can be combined with any HTTP server library or web framework of your choice. -Here's a non-exhaustive list of libraries and frameworks you can use with Prisma: +Here's a non-exhaustive list of libraries and frameworks you can use with Prisma ORM: - [Express](https://expressjs.com/) - [koa](https://koajs.com/) diff --git a/content/200-orm/050-overview/300-prisma-in-your-stack/02-graphql.mdx b/content/200-orm/050-overview/300-prisma-in-your-stack/02-graphql.mdx index 9482816f77..1d62c28c72 100644 --- a/content/200-orm/050-overview/300-prisma-in-your-stack/02-graphql.mdx +++ b/content/200-orm/050-overview/300-prisma-in-your-stack/02-graphql.mdx @@ -1,14 +1,14 @@ --- title: 'GraphQL' -metaTitle: 'Building GraphQL servers with Prisma' -metaDescription: 'This page gives explains how to build GraphQL servers with Prisma. It shows how Prisma fits into the GraphQL ecosystem and provides practical examples.' +metaTitle: 'Building GraphQL servers with Prisma ORM' +metaDescription: 'This page gives explains how to build GraphQL servers with Prisma ORM. It shows how Prisma ORM fits into the GraphQL ecosystem and provides practical examples.' --- [GraphQL](https://graphql.org/) is a query language for APIs. It is often used as an alternative to RESTful APIs, but can also be used as an additional "gateway" layer on top of existing RESTful services. -With Prisma, you can build GraphQL servers that connect to a database. Prisma is completely agnostic to the GraphQL tools you use. When building a GraphQL server, you can combine Prisma with tools like Apollo Server, GraphQL Yoga, TypeGraphQL, GraphQL.js, or pretty much any tool or library that you're using in your GraphQL server setup. +With Prisma ORM, you can build GraphQL servers that connect to a database. Prisma ORM is completely agnostic to the GraphQL tools you use. When building a GraphQL server, you can combine Prisma ORM with tools like Apollo Server, GraphQL Yoga, TypeGraphQL, GraphQL.js, or pretty much any tool or library that you're using in your GraphQL server setup. @@ -23,28 +23,28 @@ Note that a GraphQL schema can be written code-first or SDL-first. Check out thi The GraphQL schema and HTTP server are typically handled by separate libraries. Here is an overview of current GraphQL server tools and their purpose: -| Library (npm package) | Purpose | Compatible with Prisma | Prisma integration | -| :-------------------- | :-------------------------- | :--------------------- | :----------------------------------------------------------------------------- | -| `graphql` | GraphQL schema (code-first) | Yes | No | -| `graphql-tools` | GraphQL schema (SDL-first) | Yes | No | -| `type-graphql` | GraphQL schema (code-first) | Yes | [`typegraphql-prisma`](https://www.npmjs.com/package/typegraphql-prisma) | -| `nexus` | GraphQL schema (code-first) | Yes | [`nexus-prisma`](https://graphql-nexus.github.io/nexus-prisma) _Early Preview_ | -| `apollo-server` | HTTP server | Yes | n/a | -| `express-graphql` | HTTP server | Yes | n/a | -| `fastify-gql` | HTTP server | Yes | n/a | -| `graphql-yoga` | HTTP server | Yes | n/a | +| Library (npm package) | Purpose | Compatible with Prisma ORM | Prisma integration | +| :-------------------- | :-------------------------- | :------------------------- | :----------------------------------------------------------------------------- | +| `graphql` | GraphQL schema (code-first) | Yes | No | +| `graphql-tools` | GraphQL schema (SDL-first) | Yes | No | +| `type-graphql` | GraphQL schema (code-first) | Yes | [`typegraphql-prisma`](https://www.npmjs.com/package/typegraphql-prisma) | +| `nexus` | GraphQL schema (code-first) | Yes | [`nexus-prisma`](https://graphql-nexus.github.io/nexus-prisma) _Early Preview_ | +| `apollo-server` | HTTP server | Yes | n/a | +| `express-graphql` | HTTP server | Yes | n/a | +| `fastify-gql` | HTTP server | Yes | n/a | +| `graphql-yoga` | HTTP server | Yes | n/a | In addition to these standalone and single-purpose libraries, there are several projects building integrated _application frameworks_: -| Framework | Stack | Built by | Prisma | Description | -| :---------------------------------- | :-------- | :------------------------------------------------ | :--------------------- | :------------------------------------- | -| [Redwood.js](https://redwoodjs.com) | Fullstack | [Tom Preston-Werner](https://github.com/mojombo/) | Built on top of Prisma | _Bringing full-stack to the JAMstack._ | +| Framework | Stack | Built by | Prisma ORM | Description | +| :---------------------------------- | :-------- | :------------------------------------------------ | :------------------------- | :------------------------------------- | +| [Redwood.js](https://redwoodjs.com) | Fullstack | [Tom Preston-Werner](https://github.com/mojombo/) | Built on top of Prisma ORM | _Bringing full-stack to the JAMstack._ | > **Note**: If you notice any GraphQL libraries/frameworks missing from the list, please let us know. -## Prisma & GraphQL examples +## Prisma ORM & GraphQL examples -In the following section will find several ready-to-run examples that showcase how to use Prisma with different combinations of the tools mentioned in the table above. +In the following section will find several ready-to-run examples that showcase how to use Prisma ORM with different combinations of the tools mentioned in the table above. ### TypeScript @@ -74,11 +74,11 @@ In the following section will find several ready-to-run examples that showcase h ## FAQ -### What is Prisma's role in a GraphQL server? +### What is Prisma ORM's role in a GraphQL server? -No matter which of the above GraphQL tools/libraries you use, Prisma is used inside your GraphQL resolvers to connect to your database. It has the same role that any other ORM or SQL query builder would have inside your resolvers. +No matter which of the above GraphQL tools/libraries you use, Prisma ORM is used inside your GraphQL resolvers to connect to your database. It has the same role that any other ORM or SQL query builder would have inside your resolvers. -In the resolver of a GraphQL query, Prisma typically reads data from the database to return it in the GraphQL response. In the resolver of a GraphQL mutation, Prisma typically also writes data to the database (e.g. creating new or updating existing records). +In the resolver of a GraphQL query, Prisma ORM typically reads data from the database to return it in the GraphQL response. In the resolver of a GraphQL mutation, Prisma ORM typically also writes data to the database (e.g. creating new or updating existing records). ## Other GraphQL Resources 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 85bd2fc921..a888be6c0b 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 @@ -1,6 +1,6 @@ --- title: 'Fullstack' -metaTitle: 'Building fullstack applications with Prisma' +metaTitle: 'Building fullstack applications with Prisma ORM' metaDescription: 'This page gives explains how to build fullstack applications with Prisma. It shows how Prisma fits in with fullstack frameworks and provides practical examples' --- @@ -14,7 +14,7 @@ You can query your database using Prisma Client, using your framework of choice, ## Supported frameworks -Here's a non-exhaustive list of frameworks and libraries you can use with Prisma: +Here's a non-exhaustive list of frameworks and libraries you can use with Prisma ORM: - [Next.js](https://nextjs.org/) - [Remix](https://remix.run) @@ -92,7 +92,7 @@ export default async function handle(req, res) { } ``` -Note that you can use Prisma inside of Next.js API routes to send queries to your database – with REST, GraphQL, and tRPC. +Note that you can use Prisma ORM inside of Next.js API routes to send queries to your database – with REST, GraphQL, and tRPC. You can then fetch data and display it in your frontend. 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 274decd080..7f31f48a8d 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 @@ -1,24 +1,24 @@ --- -title: 'Is Prisma an ORM?' -metaTitle: 'Is Prisma an ORM? | What is an ORM?' -metaDescription: 'Learn about how Prisma implements the Data Mapper ORM pattern and how it achieves the same goal as traditional ORMs without requiring you to map classes to tables as traditional ORMs do.' +title: 'Is Prisma ORM an ORM?' +metaTitle: 'Is Prisma ORM an ORM? | What is an ORM?' +metaDescription: 'Learn about how Prisma ORM implements the Data Mapper ORM pattern and how it achieves the same goal as traditional ORMs without requiring you to map classes to tables as traditional ORMs do.' --- -To answer the question briefly: _Yes, Prisma is a new kind of ORM that fundamentally differs from traditional ORMs and doesn't suffer from many of the problems commonly associated with these_. +To answer the question briefly: _Yes, Prisma ORM is a new kind of ORM that fundamentally differs from traditional ORMs and doesn't suffer from many of the problems commonly associated with these_. Traditional ORMs provide an object-oriented way for working with relational databases by mapping tables to _model classes_ in your programming language. This approach leads to many problems that are caused by the [object-relational impedance mismatch](https://en.wikipedia.org/wiki/Object%E2%80%93relational_impedance_mismatch). -Prisma works fundamentally different compared to that. With Prisma, you define your models in the declarative [Prisma schema](/orm/prisma-schema) which serves as the single source of truth for your database schema and the models in your programming language. In your application code, you can then use Prisma Client to read and write data in your database in a type-safe manner without the overhead of managing complex model instances. This makes the process of querying data a lot more natural as well as more predictable since Prisma Client always returns plain JavaScript objects. +Prisma ORM works fundamentally different compared to that. With Prisma ORM, you define your models in the declarative [Prisma schema](/orm/prisma-schema) which serves as the single source of truth for your database schema and the models in your programming language. In your application code, you can then use Prisma Client to read and write data in your database in a type-safe manner without the overhead of managing complex model instances. This makes the process of querying data a lot more natural as well as more predictable since Prisma Client always returns plain JavaScript objects. -In this article, you will learn in more detail about ORM patterns and workflows, how Prisma implements the Data Mapper pattern, and the benefits of Prisma's approach. +In this article, you will learn in more detail about ORM patterns and workflows, how Prisma ORM implements the Data Mapper pattern, and the benefits of Prisma ORM's approach. ## What are ORMs? -If you're already familiar with ORMs, feel free to jump to the [next section](#prisma) on Prisma. +If you're already familiar with ORMs, feel free to jump to the [next section](#prisma-orm) on Prisma ORM. ### ORM Patterns - Active Record and Data Mapper @@ -142,9 +142,9 @@ export class User { Synchronizing such changes can be a challenge with ORMs because the changes are applied manually and are not easily verifiable programmatically. Renaming an existing column can be even more cumbersome and involve searching and replacing references to the column. -> **Note:** Django's [makemigrations](https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-makemigrations) CLI generates migrations by inspecting changes in models which, similar to Prisma, does away with the synchronization problem. +> **Note:** Django's [makemigrations](https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-makemigrations) CLI generates migrations by inspecting changes in models which, similar to Prisma ORM, does away with the synchronization problem. -In summary, evolving the schema is a key part of building applications. With ORMs, the workflow for updating the schema involves using a migration tool to create a migration followed by updating the corresponding entity and mapper classes (depending on the implementation). As you'll see, Prisma takes a different approach to this. +In summary, evolving the schema is a key part of building applications. With ORMs, the workflow for updating the schema involves using a migration tool to create a migration followed by updating the corresponding entity and mapper classes (depending on the implementation). As you'll see, Prisma ORM takes a different approach to this. Now that you've seen what migrations are and how they fit into the development workflows, you will learn more about the benefits and drawbacks of ORMs. @@ -168,11 +168,11 @@ The drawbacks of ORMs are not always apparent when you start using them. This se - ORMs tend to have a large API surface due to the complexity they encapsulate. The flip side of not having to write SQL is that you spend a lot of time learning how to use the ORM. This applies to most abstractions, however without understanding how the database works, improving slow queries can be difficult. - Some _complex queries_ aren't supported by ORMs due to the flexibility that SQL offers. This problem is alleviated by raw SQL querying functionality in which you pass the ORM a SQL statement string and the query is run for you. -Now that the costs and benefits of ORMs have been covered, you can better understand what Prisma is and how it fits in. +Now that the costs and benefits of ORMs have been covered, you can better understand what Prisma ORM is and how it fits in. -## Prisma +## Prisma ORM -Prisma is a **next-generation ORM** that makes working with databases easy for application developers and features the following tools: +Prisma ORM is a **next-generation ORM** that makes working with databases easy for application developers and features the following tools: - [**Prisma Client**](/orm/prisma-client): Auto-generated and type-safe database client for use in your application. - [**Prisma Migrate**](/orm/prisma-migrate): A declarative data modeling and migration tool. @@ -180,35 +180,35 @@ Prisma is a **next-generation ORM** that makes working with databases easy for a > **Note:** Since Prisma Client is the most prominent tool, we often refer to it as simply Prisma. -The three tools use the [Prisma schema](/orm/prisma-schema) as a single source of truth for the database schema, your application's object schema, and the mapping between the two. It's defined by you and is your main configuration file for Prisma. +The three tools use the [Prisma schema](/orm/prisma-schema) as a single source of truth for the database schema, your application's object schema, and the mapping between the two. It's defined by you and is your main configuration file for Prisma ORM. -Prisma makes you productive and confident in the software you're building with features such as _type safety_, rich auto-completion, and a natural API for fetching relations. +Prisma ORM makes you productive and confident in the software you're building with features such as _type safety_, rich auto-completion, and a natural API for fetching relations. -In the next section, you will learn about how Prisma implements the Data Mapper ORM pattern. +In the next section, you will learn about how Prisma ORM implements the Data Mapper ORM pattern. -### How Prisma implements the Data Mapper pattern +### How Prisma ORM implements the Data Mapper pattern As mentioned earlier in the article, the Data Mapper pattern aligns well with organizations where the database and application are owned by different teams. With the rise of modern cloud environments with managed database services and DevOps practices, more teams embrace a cross-functional approach, whereby teams own both the full development cycle including the database and operational concerns. -Prisma enables the evolution of the DB schema and object schema in tandem, thereby reducing the need for deviation in the first place, while still allowing you to keep your application and database somewhat decoupled using `@map` attributes. While this may seem like a limitation, it prevents the domain model's evolution (through the object schema) from getting imposed on the database as an afterthought. +Prisma ORM enables the evolution of the DB schema and object schema in tandem, thereby reducing the need for deviation in the first place, while still allowing you to keep your application and database somewhat decoupled using `@map` attributes. While this may seem like a limitation, it prevents the domain model's evolution (through the object schema) from getting imposed on the database as an afterthought. -To understand how Prisma's implementation of the Data Mapper pattern differs conceptually to traditional Data Mapper ORMs, here's a brief comparison of their concepts and building blocks: +To understand how Prisma ORM's implementation of the Data Mapper pattern differs conceptually to traditional Data Mapper ORMs, here's a brief comparison of their concepts and building blocks: -| Concept | Description | Building block in traditional ORMs | Building block in Prisma | Source of truth in Prisma | +| Concept | Description | Building block in traditional ORMs | Building block in Prisma ORM | Source of truth in Prisma ORM | | --------------- | -------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------------ | ------------------------------------ | | Object schema | The in-memory data structures in your applications | Model classes | Generated TypeScript types | Models in the Prisma schema | | Data Mapper | The code which transforms between the object schema and the database | Mapper classes | Generated functions in Prisma Client | @map attributes in the Prisma schema | | Database schema | The structure of data in the database, e.g., tables and columns | SQL written by hand or with a programmatic API | SQL generated by Prisma Migrate | Prisma schema | -Prisma aligns with the Data Mapper pattern with the following added benefits: +Prisma ORM aligns with the Data Mapper pattern with the following added benefits: - Reducing the boilerplate of defining classes and mapping logic by generating a Prisma Client based on the Prisma schema. - Eliminating the synchronization challenges between application objects and the database schema. - Database migrations are a first-class citizen as they're derived from the Prisma schema. -Now that we've talked about the concepts behind Prisma's approach to Data Mapper, we can go through how the Prisma schema works in practice. +Now that we've talked about the concepts behind Prisma ORM's approach to Data Mapper, we can go through how the Prisma schema works in practice. ### Prisma schema @@ -219,7 +219,7 @@ At the heart of Prisma's implementation of the Data Mapper pattern is the _Prism - Creating and evolving the database schema with Prisma Migrate. - Defining the mapping between application objects and database columns. -Models in Prisma mean something slightly different to Active Record ORMs. With Prisma, models are defined in the Prisma schema as abstract entities which describe tables, relations, and the mappings between columns to properties in Prisma Client. +Models in Prisma ORM mean something slightly different to Active Record ORMs. With Prisma ORM, models are defined in the Prisma schema as abstract entities which describe tables, relations, and the mappings between columns to properties in Prisma Client. As an example, here's a Prisma schema for a blog: @@ -253,7 +253,7 @@ model User { Here's a break down of the example above: - The `datasource` block defines the connection to the database. -- The `generator` block tells Prisma to generate Prisma Client for TypeScript and Node.js. +- The `generator` block tells Prisma ORM to generate Prisma Client for TypeScript and Node.js. - The `Post` and `User` models map to database tables. - The two models have a _1-n_ relation where each `User` can have many related `Post`s. - Each field in the models has a type, e.g. the `id` has the type `Int`. @@ -267,27 +267,27 @@ The `User` / `Post` relation can be visualized with the following diagram: ![1-n relation between User and Post](../100-introduction/user-post-relation-1-n.png) -At a Prisma level, the `User` / `Post` relation is made up of: +At a Prisma ORM level, the `User` / `Post` relation is made up of: - The scalar `authorId` field, which is referenced by the `@relation` attribute. This field exists in the database table – it is the foreign key that connects Post and User. -- The two relation fields: `author` and `posts` **do not exist** in the database table. Relation fields define connections between models at the Prisma level and exist only in the Prisma schema and generated Prisma Client, where they are used to access the relations. +- The two relation fields: `author` and `posts` **do not exist** in the database table. Relation fields define connections between models at the Prisma ORM level and exist only in the Prisma schema and generated Prisma Client, where they are used to access the relations. The declarative nature of Prisma schema is concise and allows defining the database schema and corresponding representation in Prisma Client. -In the next section, you will learn about Prisma's supported workflows. +In the next section, you will learn about Prisma ORM's supported workflows. -### Prisma workflow +### Prisma ORM workflow -The workflow with Prisma is slightly different to traditional ORMs. You can use Prisma when building new applications from scratch or adopt it incrementally: +The workflow with Prisma ORM is slightly different to traditional ORMs. You can use Prisma ORM when building new applications from scratch or adopt it incrementally: - _New application_ (greenfield): Projects that have no database schema yet can use Prisma Migrate to create the database schema. -- _Existing application_ (brownfield): Projects that already have a database schema can be [introspected](/orm/prisma-schema/introspection) by Prisma to generate the Prisma schema and Prisma Client. This use-case works with any existing migration tool and is useful for incremental adoption. It's possible to switch to Prisma Migrate as the migration tool. However, this is optional. +- _Existing application_ (brownfield): Projects that already have a database schema can be [introspected](/orm/prisma-schema/introspection) by Prisma ORM to generate the Prisma schema and Prisma Client. This use-case works with any existing migration tool and is useful for incremental adoption. It's possible to switch to Prisma Migrate as the migration tool. However, this is optional. With both workflows, the Prisma schema is the main configuration file. #### Workflow for incremental adoption in projects with an existing database -Brownfield projects typically already have some database abstraction and schema. Prisma can integrate with such projects by introspecting the existing database to obtain a Prisma schema that reflects the existing database schema and to generate Prisma Client. This workflow is compatible with any migration tool and ORM which you may already be using. If you prefer to incrementally evaluate and adopt, this approach can be used as part of a [parallel adoption strategy](https://en.wikipedia.org/wiki/Parallel_adoption). +Brownfield projects typically already have some database abstraction and schema. Prisma ORM can integrate with such projects by introspecting the existing database to obtain a Prisma schema that reflects the existing database schema and to generate Prisma Client. This workflow is compatible with any migration tool and ORM which you may already be using. If you prefer to incrementally evaluate and adopt, this approach can be used as part of a [parallel adoption strategy](https://en.wikipedia.org/wiki/Parallel_adoption). A non-exhaustive list of setups compatible with this workflow: @@ -314,17 +314,17 @@ generator client { 3. (Optional) Customize [field and model mappings](/orm/prisma-schema/data-model/models#mapping-model-names-to-tables-or-collections) between Prisma Client and the database. 4. Run `prisma generate`. -Prisma will generate Prisma Client inside the `node_modules` folder, from which it can be imported in your application. For more extensive usage documentation, see the [Prisma Client API](/orm/prisma-client) docs. +Prisma ORM will generate Prisma Client inside the `node_modules` folder, from which it can be imported in your application. For more extensive usage documentation, see the [Prisma Client API](/orm/prisma-client) docs. To summarize, Prisma Client can be integrated into projects with an existing database and tooling as part of a parallel adoption strategy. New projects will use a different workflow detailed next. #### Workflow for new projects -Prisma is different from ORMs in terms of the workflows it supports. A closer look at the steps necessary to create and change a new database schema is useful for understanding Prisma Migrate. +Prisma ORM is different from ORMs in terms of the workflows it supports. A closer look at the steps necessary to create and change a new database schema is useful for understanding Prisma Migrate. Prisma Migrate is a CLI for declarative data modeling & migrations. Unlike most migration tools that come as part of an ORM, you only need to describe the current schema, instead of the operations to move from one state to another. Prisma Migrate infers the operations, generates the SQL and carries out the migration for you. -This example demonstrates using Prisma in a new project with a new database schema similar to the blog example above: +This example demonstrates using Prisma ORM in a new project with a new database schema similar to the blog example above: 1. Create the Prisma schema: @@ -373,7 +373,7 @@ It is possible to use Prisma Client in a new project with a third-party migratio ## Accessing data with Prisma Client -So far, the article covered the concepts behind Prisma, its implementation of the Data Mapper pattern, and the workflows it supports. In this last section, you will see how to access data in your application using Prisma Client. +So far, the article covered the concepts behind Prisma ORM, its implementation of the Data Mapper pattern, and the workflows it supports. In this last section, you will see how to access data in your application using Prisma Client. 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: @@ -389,9 +389,9 @@ const user = await prisma.user.findUnique({ }) ``` -In this query, the `findUnique` method is used to fetch a single row from the `User` table. By default, Prisma will return all the scalar fields in the `User` table. +In this query, the `findUnique` method is used to fetch a single row from the `User` table. By default, Prisma ORM will return all the scalar fields in the `User` table. -> **Note:** The example uses TypeScript to make full use of the type safety features offered by Prisma Client. However, Prisma also works with [JavaScript in Node.js](https://dev.to/prisma/productive-development-with-prisma-s-zero-cost-type-safety-4od2). +> **Note:** The example uses TypeScript to make full use of the type safety features offered by Prisma Client. However, Prisma ORM also works with [JavaScript in Node.js](https://dev.to/prisma/productive-development-with-prisma-s-zero-cost-type-safety-4od2). Prisma Client maps queries and results to [structural types](https://en.wikipedia.org/wiki/Structural_type_system) by generating code from the Prisma schema. This means that `user` has an associated type in the generated Prisma Client: @@ -434,12 +434,12 @@ The example only scratches the surface of Prisma Client's API for [CRUD operatio ## Conclusion -In summary, Prisma is a new kind of Data Mapper ORM that differs from traditional ORMs and doesn't suffer from the problems commonly associated with them. +In summary, Prisma ORM is a new kind of Data Mapper ORM that differs from traditional ORMs and doesn't suffer from the problems commonly associated with them. -Unlike traditional ORMs, with Prisma, you define the Prisma schema – a declarative single source of truth for the database schema and application models. All queries in Prisma Client return plain JavaScript objects which makes the process of interacting with the database a lot more natural as well as more predictable. +Unlike traditional ORMs, with Prisma ORM, you define the Prisma schema – a declarative single source of truth for the database schema and application models. All queries in Prisma Client return plain JavaScript objects which makes the process of interacting with the database a lot more natural as well as more predictable. -Prisma supports two main workflows for starting new projects and adopting in an existing project. For both workflows, the Prisma schema is the main configuration file. +Prisma ORM supports two main workflows for starting new projects and adopting in an existing project. For both workflows, the Prisma schema is the main configuration file. -Like all abstractions, both Prisma and other ORMs hide away some of the underlying details of the database with different assumptions. +Like all abstractions, both Prisma ORM and other ORMs hide away some of the underlying details of the database with different assumptions. These differences and your use case all affect the workflow and cost of adoption. Hopefully understanding how they differ can help you make an informed decision. diff --git a/content/200-orm/050-overview/300-prisma-in-your-stack/index.mdx b/content/200-orm/050-overview/300-prisma-in-your-stack/index.mdx index 3ba9ab5661..9ba6e5baa7 100644 --- a/content/200-orm/050-overview/300-prisma-in-your-stack/index.mdx +++ b/content/200-orm/050-overview/300-prisma-in-your-stack/index.mdx @@ -1,13 +1,13 @@ --- -title: 'Prisma in your stack' -metaTitle: 'How Prisma fits into your stack' -metaDescription: 'How Prisma fits into your stack' +title: 'Prisma ORM in your stack' +metaTitle: 'How Prisma ORM fits into your stack' +metaDescription: 'How Prisma ORM fits into your stack' toc: false --- -Prisma is an ORM that provides a fully type-safe API and simplified database access. You can use Prisma tools to build a GraphQL or REST API, or as part of a fullstack application - the extent to which you incorporate Prisma is up to you. +Prisma ORM provides a fully type-safe API and simplified database access. You can use Prisma ORM tools to build a GraphQL or REST API, or as part of a fullstack application - the extent to which you incorporate Prisma ORM is up to you. 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 dcfc033995..6998d325bf 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 @@ -7,7 +7,7 @@ tocDepth: 4 ## Default built-in drivers -One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines) . The Query Engine is responsible for transforming Prisma Client queries to SQL statements. The Query Engine connects to your database using the included drivers that don't require additional setup. The built-in drivers use TCP connections to connect to the database. +One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines). The Query Engine is responsible for transforming Prisma Client queries to SQL statements. The Query Engine connects to your database via TCP using built-in drivers that don't require additional setup. ![Query flow from the user application to the database with Prisma Client](./images/drivers/qe-query-execution-flow.png) @@ -15,41 +15,44 @@ One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood Prisma Client can connect and run queries against your database using JavaScript database drivers using **driver adapters**. Adapters act as _translators_ between Prisma Client and the JavaScript database driver. -Prisma will use the Query Engine to transform the Prisma Client query to SQL and run the generated SQL queries via the JavaScript database driver. +Prisma Client will use the Query Engine to transform the Prisma Client query to SQL and run the generated SQL queries via the JavaScript database driver. ![Query flow from the user application to the database using Prisma Client and driver adapters](./images/drivers/qe-query-engine-adapter.png) -There are 2 different types of driver adapters: +There are two different types of driver adapters: - [Database driver adapters](#database-driver-adapters) - [Serverless driver adapters](#serverless-driver-adapters) +> **Note**: Driver adapters enable [edge deployments](/orm/prisma-client/deployment/edge/overview) of applications that use Prisma ORM. + ### Database driver adapters You can connect to your database using a Node.js-based driver from Prisma Client using a database driver adapter. Prisma maintains the following database driver adapters: +- [PostgreSQL](/orm/overview/databases/postgresql#using-the-node-postgres-driver) - [Turso](/orm/overview/databases/turso#how-to-connect-and-query-a-turso-database) ### Serverless driver adapters Database providers, such as Neon and PlanetScale, allow you to connect to your database using other protocols besides TCP, such as HTTP and WebSockets. These database drivers are optimized for connecting to your database in serverless and edge environments. -Prisma maintains the following serverless driver adapters: +Prisma ORM maintains the following serverless driver adapters: -- [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-preview) -- [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-preview) +- [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm-preview) +- [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview) -## Community maintained database driver adapters +### Community-maintained database driver adapters You can also build your own driver adapter for the database you're using. The following is a list of community maintained driver adapters: - [TiDB](https://github.com/tidbcloud/prisma-adapter) -### How to use driver adapters +## How to use driver adapters To use this feature: -1. Update the `previewFeatures` block in your schema to include the the `driverAdapters` preview feature: +1. Update the `previewFeatures` block in your schema to include the the `driverAdapters` Preview feature: ```prisma generator client { @@ -66,6 +69,86 @@ To use this feature: 3. Refer to the following pages to learn more how to use the specific driver adapters with the specific database providers: - - [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-preview) - - [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-preview) + - [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm-preview) + - [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview) - [Turso](/orm/overview/databases/turso#how-to-connect-and-query-a-turso-database) + +## Notes about using driver adapters + +### Driver adapters don't read the connection string from the Prisma schema + +When using Prisma ORM's built-in drivers, the connection string is read from the `url` field of the `datasource` block in your Prisma schema. + +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 highlight=5,normal +import { PrismaClient } from '@prisma/client' +import { PrismaPg } from '@prisma/adapter-pg' +import { Pool } from 'pg' + +const pool = new Pool({ connectionString: env.DATABASE_URL }) +const adapter = new PrismaPg(pool) +const prisma = new PrismaClient({ adapter }) +``` + +See the docs for the driver adapter you're using for concrete setup instructions. + +### Driver adapters and custom output paths + +Since Prisma 5.9.0, when using the driver adapters Preview feature along with a [custom output path for Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path), you cannot reference Prisma Client using a relative path. + +Let's assume you had `output` in your Prisma schema set to `../src/generated/client`: + +```prisma +generator client { + provider = "prisma-client-js" + output = "../src/generated/client" +} +``` + +What you should **not** do is reference that path relatively: + +```ts no-copy +// what not to do! +import { PrismaClient } from './src/generated/client' + +const client = new PrismaClient() +``` + +Instead, you will need to use a linked dependency. + +, , ]}> + + + +```terminal +npm add db@./src/generated/client +``` + + + + + +```terminal +pnpm add db@link:./src/generated/client +``` + + + + + +```terminal +yarn add db@link:./src/generated/client +``` + + + + + +Now you should be able to reference your generated client using `db`! + +```ts +import { PrismaClient } from 'db' + +const client = new PrismaClient() +``` 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 9add3badcb..fdc5ff4ae3 100644 --- a/content/200-orm/050-overview/500-databases/300-postgresql.mdx +++ b/content/200-orm/050-overview/500-databases/300-postgresql.mdx @@ -7,7 +7,7 @@ tocDepth: 3 -The PostgreSQL data source connector connects Prisma to a [PostgreSQL](https://www.postgresql.org/) database server. +The PostgreSQL data source connector connects Prisma ORM to a [PostgreSQL](https://www.postgresql.org/) database server. By default, the PostgreSQL connector contains a database driver responsible for connecting to your database. You can use a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) (Preview) to connect to your database using a JavaScript database driver from Prisma Client. @@ -29,11 +29,69 @@ 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. +## Using the node-postgres driver + +As of [`v5.4.0`](https://github.com/prisma/prisma/releases/tag/5.4.0), you can use Prisma ORM with database drivers from the JavaScript ecosystem (instead of using Prisma ORM's built-in drivers). You can do this by using a [driver adapter](/orm/overview/databases/database-drivers). + +For PostgreSQL, [`node-postgres`](https://node-postgres.com) (`pg`) is one of the most popular drivers in the JavaScript ecosystem. It can be used with any PostgreSQL database that's accessed via TCP. + +This section explains how you can use it with Prisma ORM and the `@prisma/adapter-pg` driver adapter. + +### 1. Enable the driverAdapters Preview feature flag + +Since driver adapters are currently in [Preview](/orm/more/releases#preview), you need to enable its feature flag on the `datasource` block in your Prisma schema: + +```prisma +// schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} +``` + +Once you have added the feature flag to your schema, re-generate Prisma Client: + +```terminal copy +npx prisma generate +``` + +### 2. Install the dependencies + +Next, install the `pg` package and Prisma ORM's driver adapter: + +```terminal copy +npm install pg +npm install @prisma/adapter-pg +``` + +### 3. Instantiate Prisma Client using the driver adapter + +Finally, when you instantiate Prisma Client, you need to pass an instance of Prisma ORM's driver adapter to the `PrismaClient` constructor: + +```ts copy +import { Pool } from 'pg' +import { PrismaPg } from '@prisma/adapter-pg' +import { PrismaClient } from '@prisma/client' + +const connectionString = `${process.env.DATABASE_URL}` + +const pool = new Pool({ connectionString }) +const adapter = new PrismaPg(pool) +const prisma = new PrismaClient({ adapter }) +``` + +Notice that this code requires the `DATABASE_URL` environment variable to be set to your PostgreSQL connection string. You can learn more about the connection string below. + ## Connection details ### Connection URL -Prisma is based on the [official PostgreSQL format](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) for connection URLs, but does not support all arguments and includes additional arguments such as `schema`. Here's an overview of the components needed for a PostgreSQL connection URL: +Prisma ORM follows the connection URL format specified by [PostgreSQL's official guidelines](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING), but does not support all arguments and includes additional arguments such as `schema`. Here's an overview of the components needed for a PostgreSQL connection URL: ![Structure of the PostgreSQL connection URL](postgresql-connection-string.png) @@ -131,15 +189,15 @@ Note that `localhost` is required, the value itself is ignored and can be anythi ## Type mapping between PostgreSQL and Prisma schema -These two tables show the type mapping between PostgreSQL and Prisma schema. First [how Prisma scalar types are translated into PostgreSQL database column types](#mapping-between-prisma-scalar-types-and-postgresql-database-column-types), and then [how PostgreSQL database column types relate to Prisma scalar and native types](#mapping-between-postgresql-database-column-types-to-prisma-scalar-and-native-types). +These two tables show the type mapping between PostgreSQL and Prisma schema. First [how Prisma ORM scalar types are translated into PostgreSQL database column types](#mapping-between-prisma-orm-scalar-types-and-postgresql-database-column-types), and then [how PostgreSQL database column types relate to Prisma ORM scalar and native types](#mapping-between-postgresql-database-column-types-to-prisma-orm-scalar-and-native-types). > Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. -### Mapping between Prisma scalar types and PostgreSQL database column types +### Mapping between Prisma ORM scalar types and PostgreSQL database column types -The PostgreSQL connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma [data model](/orm/prisma-schema/data-model/models) as follows to database column types: +The PostgreSQL connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) as follows to database column types: -| Prisma | PostgreSQL | +| Prisma ORM | PostgreSQL | | ---------- | ------------------ | | `String` | `text` | | `Boolean` | `boolean` | @@ -151,12 +209,12 @@ The PostgreSQL connector maps the [scalar types](/orm/prisma-schema/data-model/m | `Json` | `jsonb` | | `Bytes` | `bytea` | -### Mapping between PostgreSQL database column types to Prisma scalar and native types +### Mapping between PostgreSQL database column types to Prisma ORM scalar and native types -- When [introspecting](/orm/prisma-schema/introspection) a PostgreSQL database, the database types are mapped to Prisma types according to the following table. +- When [introspecting](/orm/prisma-schema/introspection) a PostgreSQL database, the database types are mapped to Prisma ORM types according to the following table. - When [creating a migration](/orm/prisma-migrate) or [prototyping your schema](/orm/prisma-migrate/workflows/prototyping-your-schema) the table is also used - in the other direction. -| PostgreSQL (Type \| Aliases) | Supported | Prisma | Native database type attribute | Notes | +| PostgreSQL (Type \| Aliases) | Supported | Prisma ORM | Native database type attribute | Notes | | ------------------------------------------- | :-------: | ------------- | :--------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `bigint` \| `int8` | ✔️ | `BigInt` | `@db.BigInt`\* | \*Default mapping for `BigInt` - no type attribute added to schema. | | `boolean` \| `bool` | ✔️ | `Bool` | `@db.Boolean`\* | \*Default mapping for `Bool` - no type attribute added to schema. | @@ -239,6 +297,6 @@ The two queries after parameterization will be the same, and the second query ca SELECT * FROM user WHERE name = $1 ``` -Every database connection maintained by Prisma has a separate cache for storing prepared statements. The size of this cache can be tweaked with the `statement_cache_size` parameter in the connection string. By default, Prisma Client caches 500 statements per connection. +Every database connection maintained by Prisma Client has a separate cache for storing prepared statements. The size of this cache can be tweaked with the `statement_cache_size` parameter in the connection string. By default, Prisma Client caches 500 statements per connection. Due to the nature of pgBouncer, if the `pgbouncer` parameter is set to `true`, the prepared statement cache is automatically disabled for that connection. 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 cabbaee1e0..0f0a2608f7 100644 --- a/content/200-orm/050-overview/500-databases/400-mysql.mdx +++ b/content/200-orm/050-overview/500-databases/400-mysql.mdx @@ -1,13 +1,13 @@ --- -title: 'MySQL' +title: 'MySQL/MariaDB' metaTitle: 'MySQL database connector' -metaDescription: 'This page explains how Prisma can connect to a MySQL database using the MySQL database connector.' +metaDescription: 'This page explains how Prisma can connect to a MySQL or MariaDB database using the MySQL database connector.' tocDepth: 3 --- -The MySQL data source connector connects Prisma to a [MySQL](https://www.mysql.com/) database server. +The MySQL data source connector connects Prisma ORM to a [MySQL](https://www.mysql.com/) or [MariaDB](https://mariadb.org/) database server. By default, the MySQL connector contains a database driver responsible for connecting to your database. You can use a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) (Preview) to connect to your database using a JavaScript database driver from Prisma Client. @@ -26,7 +26,7 @@ datasource db { The fields passed to the `datasource` block are: -- `provider`: Specifies the `mysql` data source connector. +- `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. ## Connection details @@ -50,7 +50,7 @@ The following components make up the _base URL_ of your database, they are alway | Name | Placeholder | Description | | :------- | :---------- | :------------------------------------------------------------------------------------------------------------------ | | Host | `HOST` | IP address/domain of your database server, e.g. `localhost` | -| Port | `PORT` | Port on which your database server is running, e.g. `5432` | +| Port | `PORT` | Port on which your database server is running, e.g. `5432` (default is `3306`, or no port when using Unix socket) | | User | `USER` | Name of your database user, e.g. `janedoe` | | 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` | @@ -112,8 +112,8 @@ mysql://USER:PASSWORD@HOST:PORT/DATABASE?sslidentity=client-identity.p12&sslpass ### Connecting via sockets -To connect to your MySQL database via sockets, you must add a `socket` field as a _query parameter_ to the connection URL (instead of setting it as the `host` part of the URI). -The value of this parameter then must point to the directory that contains the socket, e.g.: `mysql://USER:POST@localhost/database?socket=/var/run/mysql/` +To connect to your MySQL/MariaDB database via a socket, you must add a `socket` field as a _query parameter_ to the connection URL (instead of setting it as the `host` part of the URI). +The value of this parameter then must point to the directory that contains the socket, e.g. on a default installation of MySQL/MariaDB on Ubuntu or Debian use: `mysql://USER:POST@localhost/database?socket=/run/mysqld/mysqld.sock` Note that `localhost` is required, the value itself is ignored and can be anything. @@ -121,13 +121,13 @@ Note that `localhost` is required, the value itself is ignored and can be anythi ## Type mapping between MySQL to Prisma schema -The MySQL connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma [data model](/orm/prisma-schema/data-model/models) as follows to native column types: +The MySQL connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) as follows to native column types: -> Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. +> Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma ORM type. -### Native type mapping from Prisma to MySQL +### Native type mapping from Prisma ORM to MySQL -| Prisma | MySQL | Notes | +| Prisma ORM | MySQL | Notes | | ---------- | ---------------- | ------------------------------------------------ | | `String` | `VARCHAR(191)` | | | `Boolean` | `BOOLEAN` | In MySQL `BOOLEAN` is a synonym for `TINYINT(1)` | @@ -139,11 +139,25 @@ The MySQL connector maps the [scalar types](/orm/prisma-schema/data-model/models | `Json` | `JSON` | Supported in MySQL 5.7+ only | | `Bytes` | `LONGBLOB` | +### Native type mapping from Prisma ORM to MariaDB + +| Prisma ORM | MariaDB | Notes | +| ---------- | ---------------- | -------------------------------------------------- | +| `String` | `VARCHAR(191)` | | +| `Boolean` | `BOOLEAN` | In MariaDB `BOOLEAN` is a synonym for `TINYINT(1)` | +| `Int` | `INT` | | +| `BigInt` | `BIGINT` | | +| `Float` | `DOUBLE` | | +| `Decimal` | `DECIMAL(65,30)` | | +| `DateTime` | `DATETIME(3)` | | +| `Json` | `LONGTEXT` | See https://mariadb.com/kb/en/json-data-type/ | +| `Bytes` | `LONGBLOB` | | + ### Native type mappings -When introspecting a MySQL database, the database types are mapped to Prisma according to the following table: +When introspecting a MySQL database, the database types are mapped to Prisma ORM according to the following table: -| MySQL | Prisma | Supported | Native database type attribute | Notes | +| MySQL | Prisma ORM | Supported | Native database type attribute | Notes | | ------------------------- | ------------- | --------- | ---------------------------------------------- | ------------------------------------------------------------------ | | `serial` | `BigInt` | ✔️ | `@db.UnsignedBigInt @default(autoincrement())` | | `bigint` | `BigInt` | ✔️ | `@db.BigInt` | @@ -204,3 +218,18 @@ model Device { ## Engine If you are using a version of MySQL where MyISAM is the default engine, you must specify `ENGINE = InnoDB;` when you create a table. If you introspect a database that uses a different engine, relations in the Prisma Schema are not created (or lost, if the relation already existed). + +## Permissions + +A fresh new installation of MySQL/MariaDB has by default only a `root` database user. Do not use `root` user in your Prisma configuration, but instead create a database and database user for each application. On most Linux hosts (e.g. Ubuntu) you can simply run this as the Linux `root` user (which automatically has database `root` access as well): + +``` +mysql -e "CREATE DATABASE IF NOT EXISTS $DB_PRISMA;" +mysql -e "GRANT ALL PRIVILEGES ON $DB_PRISMA.* TO $DB_USER@'%' IDENTIFIED BY '$DB_PASSWORD';" +``` + +The above is enough to run the `prisma db pull` and `prisma db push` commands. In order to also run `prisma migrate` commands these permissions need to be granted: + +``` +mysql -e "GRANT CREATE, DROP, REFERENCES, ALTER ON *.* TO $DB_USER@'%';" +``` 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 fc31ca5d47..907eee0dce 100644 --- a/content/200-orm/050-overview/500-databases/500-sqlite.mdx +++ b/content/200-orm/050-overview/500-databases/500-sqlite.mdx @@ -7,7 +7,7 @@ tocDepth: 3 -The SQLite data source connector connects Prisma to a [SQLite](https://www.sqlite.org/) database file. These files always have the file ending `.db` (e.g.: `dev.db`). +The SQLite data source connector connects Prisma ORM to a [SQLite](https://www.sqlite.org/) database file. These files always have the file ending `.db` (e.g.: `dev.db`). By default, the SQLite connector contains a database driver responsible for connecting to your database. You can use a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) (Preview) to connect to your database using a JavaScript database driver from Prisma Client. @@ -33,11 +33,11 @@ The fields passed to the `datasource` block are: The SQLite connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the [data model](/orm/prisma-schema/data-model/models) to native column types as follows: -> Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. +> Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma ORM type. -### Native type mapping from Prisma to SQLite +### Native type mapping from Prisma ORM to SQLite -| Prisma | SQLite | +| Prisma ORM | SQLite | | ---------- | ------------- | | `String` | `TEXT` | | `Boolean` | `BOOLEAN` | @@ -51,9 +51,9 @@ The SQLite connector maps the [scalar types](/orm/prisma-schema/data-model/model ## Rounding errors on big numbers -SQLite is a loosely-typed database. If your Schema has a field of type `Int`, then Prisma prevents you from inserting a value larger than an integer. However, nothing prevents the database from directly accepting a bigger number. These manually-inserted big numbers cause rounding errors when queried. +SQLite is a loosely-typed database. If your Schema has a field of type `Int`, then Prisma ORM prevents you from inserting a value larger than an integer. However, nothing prevents the database from directly accepting a bigger number. These manually-inserted big numbers cause rounding errors when queried. -To avoid this problem, Prisma 4.0.0 and later checks numbers on the way out of the database to verify that they fit within the boundaries of an integer. If a number does not fit, then Prisma throws a P2023 error, such as: +To avoid this problem, Prisma ORM 4.0.0 and later checks numbers on the way out of the database to verify that they fit within the boundaries of an integer. If a number does not fit, then Prisma ORM throws a P2023 error, such as: ``` Inconsistent column data: Conversion failed: 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 8f1f9fee79..d47cfe9612 100644 --- a/content/200-orm/050-overview/500-databases/600-mongodb.mdx +++ b/content/200-orm/050-overview/500-databases/600-mongodb.mdx @@ -9,11 +9,11 @@ codeStyle: false -This guide discusses the concepts behind using Prisma 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. +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. -To connect Prisma with MongoDB, refer to our [Getting Started documentation](/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb). +To connect Prisma ORM with MongoDB, refer to our [Getting Started documentation](/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb). @@ -23,11 +23,11 @@ To connect Prisma with MongoDB, refer to our [Getting Started documentation](/ge [MongoDB](https://www.mongodb.com/) is a NoSQL database that stores data in [BSON](https://bsonspec.org/) format, a JSON-like document format designed for storing data in key-value pairs. It is commonly used in JavaScript application development because the document model maps easily to objects in application code, and there is built in support for high availability and horizontal scaling. -MongoDB stores data in collections that do not need a schema to be defined in advance, as you would need to do with tables in a relational database. The structure of each collection can also be changed over time. This flexibility can allow rapid iteration of your data model, but it does mean that there are a number of differences when using Prisma to work with your MongoDB database. +MongoDB stores data in collections that do not need a schema to be defined in advance, as you would need to do with tables in a relational database. The structure of each collection can also be changed over time. This flexibility can allow rapid iteration of your data model, but it does mean that there are a number of differences when using Prisma ORM to work with your MongoDB database. ## Commonalities with other database providers -Some aspects of using Prisma with MongoDB are the same as when using Prisma with a relational database. You can still: +Some aspects of using Prisma ORM with MongoDB are the same as when using Prisma ORM with a relational database. You can still: - model your database with the [Prisma Schema Language](/orm/prisma-schema) - connect to your database, using the [`mongodb` database connector](/orm/overview/databases) @@ -37,19 +37,19 @@ Some aspects of using Prisma with MongoDB are the same as when using Prisma with ## Differences to consider -MongoDB's document-based structure and flexible schemas means that using Prisma with MongoDB differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of: +MongoDB's document-based structure and flexible schemas means that using Prisma ORM with MongoDB differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of: -- **Defining IDs**: MongoDB documents have an `_id` field (that often contains an [ObjectID](https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-objectid)). Prisma does not support fields starting with `_`, so this needs to be mapped to a Prisma field using the `@map` attribute. For more information, see [Defining IDs in MongoDB](/orm/prisma-schema/data-model/models#defining-ids-in-mongodb). +- **Defining IDs**: MongoDB documents have an `_id` field (that often contains an [ObjectID](https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-objectid)). Prisma ORM does not support fields starting with `_`, so this needs to be mapped to a Prisma ORM field using the `@map` attribute. For more information, see [Defining IDs in MongoDB](/orm/prisma-schema/data-model/models#defining-ids-in-mongodb). - **Migrating existing data to match your Prisma schema**: In relational databases, all your data must match your schema. If you change the type of a particular field in your schema when you migrate, all the data must also be updated to match. In contrast, MongoDB does not enforce any particular schema, so you need to take care when migrating. For more information, see [How to migrate old data to new schemas](#how-to-migrate-existing-data-to-match-your-prisma-schema). -- **Introspection and Prisma relations**: When you introspect an existing MongoDB database, you will get a schema with no relations and will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection). +- **Introspection and Prisma ORM relations**: When you introspect an existing MongoDB database, you will get a schema with no relations and will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection). -- **Filtering for `null` and missing fields**: MongoDB makes a distinction between setting a field to `null` and not setting it at all, which is not present in relational databases. Prisma currently does not express this distinction, which means that you need to be careful when filtering for `null` and missing fields. For more information, see [How to filter for `null` and missing fields](#how-to-filter-for-null-and-missing-fields) +- **Filtering for `null` and missing fields**: MongoDB makes a distinction between setting a field to `null` and not setting it at all, which is not present in relational databases. Prisma ORM currently does not express this distinction, which means that you need to be careful when filtering for `null` and missing fields. For more information, see [How to filter for `null` and missing fields](#how-to-filter-for-null-and-missing-fields) -- **Enabling replication**: Prisma uses [MongoDB transactions](https://www.mongodb.com/docs/manual/core/transactions/) internally to avoid partial writes on nested queries. When using transactions, MongoDB requires replication of your data set to be enabled. To do this, you will need to configure a [replica set](https://www.mongodb.com/docs/manual/replication/) — this is a group of MongoDB processes that maintain the same data set. Note that it is still possible to use a single database, by creating a replica set with only one node in it. If you use MongoDB's [Atlas](https://www.mongodb.com/atlas/database) hosting service, the replica set is configured for you, but if you are running MongoDB locally you will need to set up a replica set yourself. For more information, see MongoDB's [guide to deploying a replica set](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/). +- **Enabling replication**: Prisma ORM uses [MongoDB transactions](https://www.mongodb.com/docs/manual/core/transactions/) internally to avoid partial writes on nested queries. When using transactions, MongoDB requires replication of your data set to be enabled. To do this, you will need to configure a [replica set](https://www.mongodb.com/docs/manual/replication/) — this is a group of MongoDB processes that maintain the same data set. Note that it is still possible to use a single database, by creating a replica set with only one node in it. If you use MongoDB's [Atlas](https://www.mongodb.com/atlas/database) hosting service, the replica set is configured for you, but if you are running MongoDB locally you will need to set up a replica set yourself. For more information, see MongoDB's [guide to deploying a replica set](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/). -## How to use Prisma with MongoDB +## How to use Prisma ORM with MongoDB This section provides instructions for how to carry out tasks that require steps specific to MongoDB. @@ -104,13 +104,13 @@ There are a number of strategies you could use for migrating this schema: Then when you encounter a missing `phoneNumber`, the value will be coerced into `000-000-0000`. -- **"No breaking changes" updates**: this strategy builds on the first one, with further consensus amongst your team that you don't rename or delete fields, only add new fields, and always define the new fields as optional. This policy can be reenforced by adding checks in the CI/CD process to verify that there are no backwards-incompatible changes to the schema. +- **"No breaking changes" updates**: this strategy builds on the first one, with further consensus amongst your team that you don't rename or delete fields, only add new fields, and always define the new fields as optional. This policy can be reinforced by adding checks in the CI/CD process to verify that there are no backwards-incompatible changes to the schema. - **"All-at-once" updates**: this strategy is similar to traditional migrations in relational databases, where all data is updated to reflect the new schema. In the scenario above, you would create a script to add a value for the phone number field to all existing users in your database. You can then make the field a required field in the application because the schema and the data are consistent. ### How to add in missing relations after Introspection -After introspecting an existing MongoDB database, you will need to manually add in relations between models. MongoDB does not have the concept of defining relations via foreign keys, as you would in a relational database. However, if you have a collection in MongoDB with a "foreign-key-like" field that matches the ID field of another collection, Prisma will allow you to emulate relations between the collections. +After introspecting an existing MongoDB database, you will need to manually add in relations between models. MongoDB does not have the concept of defining relations via foreign keys, as you would in a relational database. However, if you have a collection in MongoDB with a "foreign-key-like" field that matches the ID field of another collection, Prisma ORM will allow you to emulate relations between the collections. As an example, take a MongoDB database with two collections, `User` and `Post`. The data in these collections has the following format, with a `userId` field linking users to posts: @@ -157,7 +157,7 @@ model User { } ``` -For more information on how to use relations in Prisma, see [our documentation](/orm/prisma-schema/data-model/relations). +For more information on how to use relations in Prisma ORM, see [our documentation](/orm/prisma-schema/data-model/relations). ### How to filter for null and missing fields @@ -171,7 +171,7 @@ model User { } ``` -First, try creating a record with the `name` field explicitly set to `null`. Prisma will return `name: null` as expected: +First, try creating a record with the `name` field explicitly set to `null`. Prisma ORM will return `name: null` as expected: @@ -244,7 +244,7 @@ console.log(createMissing) -Prisma still returns `name: null`, but if you look in the database directly you will see that the record has no `name` field defined at all: +Prisma ORM still returns `name: null`, but if you look in the database directly you will see that the record has no `name` field defined at all: ```json { @@ -253,7 +253,7 @@ Prisma still returns `name: null`, but if you look in the database directly you } ``` -Prisma returns the same result in both cases, because we currently don't have a way to specify this difference in MongoDB between fields that are `null` in the underlying database, and fields that are not defined at all — see [this Github issue](https://github.com/prisma/prisma/issues/12555) for more information. +Prisma ORM returns the same result in both cases, because we currently don't have a way to specify this difference in MongoDB between fields that are `null` in the underlying database, and fields that are not defined at all — see [this Github issue](https://github.com/prisma/prisma/issues/12555) for more information. This means that you currently have to be careful when filtering for `null` and missing fields. Filtering for records with `name: null` will only return the first record, with the `name` explicitly set to `null`: @@ -337,9 +337,9 @@ console.log(findNullOrMissing) -## More on using MongoDB with Prisma +## More on using MongoDB with Prisma ORM -The fastest way to start using MongoDB with Prisma is to refer to our Getting Started documentation: +The fastest way to start using MongoDB with Prisma ORM is to refer to our Getting Started documentation: - [Start from scratch](/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb) - [Add to existing project](/getting-started/setup-prisma/add-to-existing-project/mongodb-typescript-mongodb) @@ -416,7 +416,7 @@ A connection URL can also take arguments. The following example sets three argum mongodb://USERNAME:PASSWORD@HOST/DATABASE?ssl=true&connectTimeoutMS=5000&maxPoolSize=50 ``` -Refer to the [MongoDB connection string documentation](https://docs.mongodb.com/manual/reference/connection-string/#connection-string-options) for a complete list of connection string arguments. There are no Prisma-specific arguments. +Refer to the [MongoDB connection string documentation](https://docs.mongodb.com/manual/reference/connection-string/#connection-string-options) for a complete list of connection string arguments. There are no Prisma ORM-specific arguments. ## Using ObjectId @@ -474,7 +474,7 @@ const id = new ObjectId() ## Differences to connectors for relational databases -This section covers ways in which the MongoDB connector differs from Prisma connectors for relational databases. +This section covers ways in which the MongoDB connector differs from Prisma ORM connectors for relational databases. ### No support for Prisma Migrate @@ -496,9 +496,9 @@ See [Special rules for referential actions](/orm/prisma-schema/data-model/relati ### Replica set configuration -MongoDB only allows you to start a transaction on a replica set. Prisma uses transactions internally to avoid partial writes on nested queries. This means we inherit the requirement of needing a replica set configured. +MongoDB only allows you to start a transaction on a replica set. Prisma ORM uses transactions internally to avoid partial writes on nested queries. This means we inherit the requirement of needing a replica set configured. -When you try to use Prisma's MongoDB connector on a deployment that has no replica set configured, Prisma shows the message `Error: Transactions are not supported by this deployment`. The full text of the error message is the following: +When you try to use Prisma ORM's MongoDB connector on a deployment that has no replica set configured, Prisma ORM shows the message `Error: Transactions are not supported by this deployment`. The full text of the error message is the following: ``` PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: @@ -524,13 +524,13 @@ There's also an option to run the replica set locally with this guide: https://d ## Type mapping between MongoDB and the Prisma schema -The MongoDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma [data model](/orm/prisma-schema/data-model/models) to MongoDB's native column types as follows: +The MongoDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) to MongoDB's native column types as follows: > Alternatively, see [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. -### Native type mapping from Prisma to MongoDB +### Native type mapping from Prisma ORM to MongoDB -| Prisma | MongoDB | +| Prisma ORM | MongoDB | | ---------- | ---------------------------------------------------------------------- | | `String` | `string` | | `Boolean` | `bool` | @@ -556,13 +556,13 @@ MongoDB types that are currently unsupported: - `JavascriptWithScope` - `Regex` -### Mapping from MongoDB to Prisma types on Introspection +### Mapping from MongoDB to Prisma ORM types on Introspection -When introspecting a MongoDB database, Prisma uses the relevant [scalar types](/orm/prisma-schema/data-model/models#scalar-fields). Some special types also get additional native type annotations: +When introspecting a MongoDB database, Prisma ORM uses the relevant [scalar types](/orm/prisma-schema/data-model/models#scalar-fields). Some special types also get additional native type annotations: -| MongoDB (Type \| Aliases) | Prisma | Supported | Native database type attribute | Notes | -| ------------------------- | -------- | :-------: | :----------------------------- | :---- | -| `objectId` | `String` | ✔️ | `@db.ObjectId` | | +| MongoDB (Type \| Aliases) | Prisma ORM | Supported | Native database type attribute | Notes | +| ------------------------- | ---------- | :-------: | :----------------------------- | :---- | +| `objectId` | `String` | ✔️ | `@db.ObjectId` | | [Introspection](/orm/prisma-schema/introspection) adds native database types that are **not yet supported** as [`Unsupported`](/orm/reference/prisma-schema-reference#unsupported) fields: 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 79dcac9272..b108abfd89 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 @@ -7,7 +7,7 @@ tocDepth: 4 -The Microsoft SQL Server data source connector connects Prisma to a [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/sql-server/?view=sql-server-ver15) database server. +The Microsoft SQL Server data source connector connects Prisma ORM to a [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/sql-server/?view=sql-server-ver15) database server. @@ -97,7 +97,7 @@ sqlserver://mycomputer\sql2019;database=sample;integratedSecurity=true;trustServ ## Type mapping between Microsoft SQL Server to Prisma schema -For type mappings organized by Prisma type, refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) documentation. +For type mappings organized by Prisma ORM type, refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) documentation. ## Supported versions @@ -115,7 +115,7 @@ SQL Server does not have an equivalent to the PostgreSQL `SET search_path` comma #### Cyclic references -Circular references can occur between models when each model references another, creating a closed loop. When using a Microsoft SQL Server database, Prisma will show a validation error if the [referential action](/orm/prisma-schema/data-model/relations/referential-actions) on a relation is set to something other than [`NoAction`](/orm/prisma-schema/data-model/relations/referential-actions#noaction). +Circular references can occur between models when each model references another, creating a closed loop. When using a Microsoft SQL Server database, Prisma ORM will show a validation error if the [referential action](/orm/prisma-schema/data-model/relations/referential-actions) on a relation is set to something other than [`NoAction`](/orm/prisma-schema/data-model/relations/referential-actions#noaction). See [Special rules for referential actions in SQL Server](/orm/prisma-schema/data-model/relations/referential-actions/special-rules-for-referential-actions) for more information. @@ -141,7 +141,7 @@ CREATE TABLE cats ( sp_bindefault 'catcat', 'dbo.cats.name'; ``` -Using the stored procedure `sp_bindefault`, the default value `catcat` can be used in more than one table. The way Prisma manages default values is per table: +Using the stored procedure `sp_bindefault`, the default value `catcat` can be used in more than one table. The way Prisma ORM manages default values is per table: ```sql file=default_per_table.sql CREATE TABLE cats ( diff --git a/content/200-orm/050-overview/500-databases/860-cockroachdb.mdx b/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx similarity index 69% rename from content/200-orm/050-overview/500-databases/860-cockroachdb.mdx rename to content/200-orm/050-overview/500-databases/840-cockroachdb.mdx index eda18fc474..c2a101ee4b 100644 --- a/content/200-orm/050-overview/500-databases/860-cockroachdb.mdx +++ b/content/200-orm/050-overview/500-databases/840-cockroachdb.mdx @@ -8,7 +8,7 @@ toc: true -This guide discusses the concepts behind using Prisma and CockroachDB, explains the commonalities and differences between CockroachDB and other database providers, and leads you through the process for configuring your application to integrate with CockroachDB. +This guide discusses the concepts behind using Prisma ORM and CockroachDB, explains the commonalities and differences between CockroachDB and other database providers, and leads you through the process for configuring your application to integrate with CockroachDB. @@ -22,35 +22,34 @@ The CockroachDB connector is generally available in versions `3.14.0` and later. CockroachDB is a distributed database that is designed for scalability and high availability. Features include: -- **Built-in scaling:** CockroachDB comes with automated replication, failover and repair capabilities to allow easy horizontal scaling of your application -- **Consistent transactions:** CockroachDB is a relational database that supports consistent transactions that maintain data integrity - **Compatibility with PostgreSQL:** CockroachDB is compatible with PostgreSQL, allowing interoperability with a large ecosystem of existing products +- **Built-in scaling:** CockroachDB comes with automated replication, failover and repair capabilities to allow easy horizontal scaling of your application ## Commonalities with other database providers -CockroachDB is largely compatible with PostgreSQL, and can mostly be used with Prisma in the same way. You can still: +CockroachDB is largely compatible with PostgreSQL, and can mostly be used with Prisma ORM in the same way. You can still: - model your database with the [Prisma Schema Language](/orm/prisma-schema) -- connect to your database, using Prisma's [`cockroachdb` database connector](/orm/overview/databases/cockroachdb) +- connect to your database, using Prisma ORM's [`cockroachdb` database connector](/orm/overview/databases/cockroachdb) - use [Introspection](/orm/prisma-schema/introspection) for existing projects if you already have a CockroachDB database - use [Prisma Migrate](/orm/prisma-migrate) to migrate your database schema to a new version - use [Prisma Client](/orm/prisma-client) in your application to query your database in a type safe way based on your Prisma Schema ## Differences to consider -There are some CockroachDB-specific differences to be aware of when working with Prisma's `cockroachdb` connector: +There are some CockroachDB-specific differences to be aware of when working with Prisma ORM's `cockroachdb` connector: -- **Cockroach-specific native types:** Prisma's `cockroachdb` database connector provides support for CockroachDB's native data types. To learn more, see [How to use CockroachDB's native types](#how-to-use-cockroachdbs-native-types). +- **Cockroach-specific native types:** Prisma ORM's `cockroachdb` database connector provides support for CockroachDB's native data types. To learn more, see [How to use CockroachDB's native types](#how-to-use-cockroachdbs-native-types). -- **Creating database keys:** Prisma allows you to generate a unique identifier for each record using the [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincrement) function. For more information, see [How to use database keys with CockroachDB](#how-to-use-database-keys-with-cockroachdb). +- **Creating database keys:** Prisma ORM allows you to generate a unique identifier for each record using the [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincrement) function. For more information, see [How to use database keys with CockroachDB](#how-to-use-database-keys-with-cockroachdb). -## How to use Prisma with CockroachDB +## How to use Prisma ORM with CockroachDB This section provides more details on how to use CockroachDB-specific features. ### How to use CockroachDB's native types -CockroachDB has its own set of native [data types](https://www.cockroachlabs.com/docs/stable/data-types.html) which are supported in Prisma. For example, CockroachDB uses the `STRING` data type instead of PostgreSQL's `VARCHAR`. +CockroachDB has its own set of native [data types](https://www.cockroachlabs.com/docs/stable/data-types.html) which are supported in Prisma ORM. For example, CockroachDB uses the `STRING` data type instead of PostgreSQL's `VARCHAR`. As a demonstration of this, say you create a `User` table in your CockroachDB database using the following SQL command: @@ -80,7 +79,7 @@ For a full list of type mappings, see our [connector documentation](/orm/overvie When generating unique identifiers for records in a distributed database like CockroachDB, it is best to avoid using sequential IDs – for more information on this, see CockroachDB's [blog post on choosing index keys](https://cockroachlabs.com/blog/how-to-choose-db-index-keys). -Instead, Prisma provides the [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincrement) attribute function, which uses CockroachDB's [`unique_rowid()` function](https://www.cockroachlabs.com/docs/stable/serial.html) for generating unique identifiers. For example, the following `User` model has an `id` primary key, generated using the `autoincrement()` function: +Instead, Prisma ORM provides the [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincrement) attribute function, which uses CockroachDB's [`unique_rowid()` function](https://www.cockroachlabs.com/docs/stable/serial.html) for generating unique identifiers. For example, the following `User` model has an `id` primary key, generated using the `autoincrement()` function: ```prisma file=schema.prisma model User { @@ -89,7 +88,7 @@ model User { } ``` -For compatibility with existing databases, you may sometimes still need to generate a fixed sequence of integer key values. In these cases, you can use Prisma's inbuilt [`sequence()`](/orm/reference/prisma-schema-reference#sequence) function for CockroachDB. For a list of available options for the `sequence()` function, see our [reference documentation](/orm/reference/prisma-schema-reference#sequence). +For compatibility with existing databases, you may sometimes still need to generate a fixed sequence of integer key values. In these cases, you can use Prisma ORM's inbuilt [`sequence()`](/orm/reference/prisma-schema-reference#sequence) function for CockroachDB. For a list of available options for the `sequence()` function, see our [reference documentation](/orm/reference/prisma-schema-reference#sequence). For more information on generating database keys, see CockroachDB's [Primary key best practices](https://www.cockroachlabs.com/docs/v21.2/schema-design-table#primary-key-best-practices) guide. @@ -125,43 +124,43 @@ The following table lists differences between CockroachDB and PostgreSQL: | Issue | Area | Notes | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| By default, the `INT` type is an alias for `INT8` in CockroachDB, whereas in PostgreSQL it is an alias for `INT4`. This means that Prisma will introspect an `INT` column in CockroachDB as `BigInt`, whereas in PostgreSQL Prisma will introspect it as `Int`. | Schema | For more information on the `INT` type, see the [CockroachDB documentation](https://www.cockroachlabs.com/docs/stable/int.html#considerations-for-64-bit-signed-integers) | +| By default, the `INT` type is an alias for `INT8` in CockroachDB, whereas in PostgreSQL it is an alias for `INT4`. This means that Prisma ORM will introspect an `INT` column in CockroachDB as `BigInt`, whereas in PostgreSQL Prisma ORM will introspect it as `Int`. | Schema | For more information on the `INT` type, see the [CockroachDB documentation](https://www.cockroachlabs.com/docs/stable/int.html#considerations-for-64-bit-signed-integers) | | When using `@default(autoincrement())` on a field, CockroachDB will automatically generate 64-bit integers for the row IDs. These integers will be increasing but not consecutive. This is in contrast to PostgreSQL, where generated row IDs are consecutive and start from 1. | Schema | For more information on generated values, see the [CockroachDB documentation](https://www.cockroachlabs.com/docs/stable/serial.html#generated-values-for-modes-rowid-and-virtual_sequence) | | The `@default(autoincrement())` attribute can only be used together with the `BigInt` field type. | Schema | For more information on generated values, see the [CockroachDB documentation](https://www.cockroachlabs.com/docs/stable/serial.html#generated-values-for-modes-rowid-and-virtual_sequence) | ## Type mapping limitations in CockroachDB -The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma [data model](/orm/prisma-schema/data-model/models) to native column types. These native types are mostly the same as for PostgreSQL — see the [Native type mapping from Prisma to CockroachDB](#native-type-mapping-from-prisma-to-cockroachdb) for details. However, there are some limitations: +The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) to native column types. These native types are mostly the same as for PostgreSQL — see the [Native type mapping from Prisma ORM to CockroachDB](#native-type-mapping-from-prisma-orm-to-cockroachdb) for details. However, there are some limitations: -| CockroachDB (Type \| Aliases) | Prisma | Supported | Native database type attribute | Notes | -| ----------------------------- | --------- | :-------: | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------- | -| `money` | `Decimal` | Not yet | `@db.Money` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41578) | -| `xml` | `String` | Not yet | `@db.Xml` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/43355) | -| `jsonb` arrays | `Json[]` | Not yet | N/A | `Json[]` supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/23468) | +| CockroachDB (Type \| Aliases) | Prisma ORM | Supported | Native database type attribute | Notes | +| ----------------------------- | ---------- | :-------: | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------- | +| `money` | `Decimal` | Not yet | `@db.Money` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41578) | +| `xml` | `String` | Not yet | `@db.Xml` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/43355) | +| `jsonb` arrays | `Json[]` | Not yet | N/A | `Json[]` supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/23468) | ## Other limitations The following table lists any other current known limitations of CockroachDB compared to PostgreSQL: -| Issue | Area | Notes | -| ------------------------------------------------------------------------------------------------ | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Primary keys are named `primary` instead of `TABLE_pkey`, the Prisma default. | Introspection | This means that they are introspected as `@id(map: "primary")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70604). | -| Foreign keys are named `fk_COLUMN_ref_TABLE` instead of `TABLE_COLUMN_fkey`, the Prisma default. | Introspection | This means that they are introspected as `@relation([...], map: "fk_COLUMN_ref_TABLE")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70658) | -| Index types `Hash`, `Gist`, `SpGist` or `Brin` are not supported. | Schema | In PostgreSQL, Prisma allows [configuration of indexes](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql) to use the different index access method. CockroachDB only currently supports `BTree` and `Gin`. | -| Pushing to `Enum` types not supported | Client | Pushing to `Enum` types (e.g. `data: { enum { push: "A" }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/71388) | -| Searching on `String` fields without a full text index not supported | Client | Searching on `String` fields without a full text index (e.g. `where: { text: { search: "cat & dog", }, },`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/7821) | -| Integer division not supported | Client | Integer division (e.g. `data: { int: { divide: 10, }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41448) | -| Limited filtering on `Json` fields | Client | Currently CockroachDB [only supports](https://github.com/cockroachdb/cockroach/issues/49144) `equals` and `not` filtering on `Json` fields | +| Issue | Area | Notes | +| ---------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Primary keys are named `primary` instead of `TABLE_pkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@id(map: "primary")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70604). | +| Foreign keys are named `fk_COLUMN_ref_TABLE` instead of `TABLE_COLUMN_fkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@relation([...], map: "fk_COLUMN_ref_TABLE")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70658) | +| Index types `Hash`, `Gist`, `SpGist` or `Brin` are not supported. | Schema | In PostgreSQL, Prisma ORM allows [configuration of indexes](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql) to use the different index access method. CockroachDB only currently supports `BTree` and `Gin`. | +| Pushing to `Enum` types not supported | Client | Pushing to `Enum` types (e.g. `data: { enum { push: "A" }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/71388) | +| Searching on `String` fields without a full text index not supported | Client | Searching on `String` fields without a full text index (e.g. `where: { text: { search: "cat & dog", }, },`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/7821) | +| Integer division not supported | Client | Integer division (e.g. `data: { int: { divide: 10, }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41448) | +| Limited filtering on `Json` fields | Client | Currently CockroachDB [only supports](https://github.com/cockroachdb/cockroach/issues/49144) `equals` and `not` filtering on `Json` fields | ## Type mapping between CockroachDB and the Prisma schema -The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma [data model](/orm/prisma-schema/data-model/models) as follows to native column types: +The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) as follows to native column types: -> Alternatively, see the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma type. +> Alternatively, see the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) for type mappings organized by Prisma ORM type. -### Native type mapping from Prisma to CockroachDB +### Native type mapping from Prisma ORM to CockroachDB -| Prisma | CockroachDB | +| Prisma ORM | CockroachDB | | ---------- | ---------------- | | `String` | `STRING` | | `Boolean` | `BOOL` | @@ -173,11 +172,11 @@ The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/ | `Json` | `JSONB` | | `Bytes` | `BYTES` | -### Mapping from CockroachDB to Prisma types on Introspection +### Mapping from CockroachDB to Prisma ORM types on Introspection -When introspecting a CockroachDB database, the database types are mapped to Prisma according to the following table: +When introspecting a CockroachDB database, the database types are mapped to Prisma ORM according to the following table: -| CockroachDB (Type \| Aliases) | Prisma | Supported | Native database type attribute | Notes | +| CockroachDB (Type \| Aliases) | Prisma ORM | Supported | Native database type attribute | Notes | | -------------------------------------------- | ---------- | :-------: | :----------------------------- | :--------------------------------------------------------------------- | | `INT` \| `BIGINT`, `INTEGER` | `BigInt` | ✔️ | `@db.Int8` | | | `BOOL` \| `BOOLEAN` | `Bool` | ✔️ | `@db.Bool`\* | | @@ -212,9 +211,9 @@ model Device { } ``` -## More on using CockroachDB with Prisma +## More on using CockroachDB with Prisma ORM -The fastest way to start using CockroachDB with Prisma is to refer to our Getting Started documentation: +The fastest way to start using CockroachDB with Prisma ORM is to refer to our Getting Started documentation: - [Start from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-cockroachdb) - [Add to existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-cockroachdb) 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 720823470a..6cd9bda929 100644 --- a/content/200-orm/050-overview/500-databases/850-planetscale.mdx +++ b/content/200-orm/050-overview/500-databases/850-planetscale.mdx @@ -10,7 +10,7 @@ toc: true Prisma and [PlanetScale](https://planetscale.com/) together provide a development arena that optimizes rapid, type-safe development of data access applications, using Prisma's ORM and PlanetScale's highly scalable MySQL-based platform. -This document discusses the concepts behind using Prisma and PlanetScale, explains the commonalities and differences between PlanetScale and other database providers, and leads you through the process for configuring your application to integrate with PlanetScale. +This document discusses the concepts behind using Prisma ORM and PlanetScale, explains the commonalities and differences between PlanetScale and other database providers, and leads you through the process for configuring your application to integrate with PlanetScale. @@ -24,48 +24,50 @@ PlanetScale uses the [Vitess](https://vitess.io/) database clustering system to ## Commonalities with other database providers -Many aspects of using Prisma with PlanetScale are just like using Prisma with any other relational database. You can still: +Many aspects of using Prisma ORM with PlanetScale are just like using Prisma ORM with any other relational database. You can still: - model your database with the [Prisma Schema Language](/orm/prisma-schema) -- use Prisma's existing [`mysql` database connector](/orm/overview/databases/mysql) in your schema, along with the [connection string PlanetScale provides you](https://planetscale.com/docs/concepts/connection-strings) +- use Prisma ORM's existing [`mysql` database connector](/orm/overview/databases/mysql) in your schema, along with the [connection string PlanetScale provides you](https://planetscale.com/docs/concepts/connection-strings) - use [Introspection](/orm/prisma-schema/introspection) for existing projects if you already have a database schema in PlanetScale - use [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) to push changes in your schema to the database - use [Prisma Client](/orm/prisma-client) in your application to talk to the database server at PlanetScale ## Differences to consider -PlanetScale's branching model and design for scalability means that there are also a number of differences to consider. You should be aware of the following points when deciding to use PlanetScale with Prisma: +PlanetScale's branching model and design for scalability means that there are also a number of differences to consider. You should be aware of the following points when deciding to use PlanetScale with Prisma ORM: - **Branching and deploy requests.** PlanetScale provides two types of database branches: _development branches_, which allow you to test out schema changes, and _production branches_, which are protected from direct schema changes. Instead, changes must be first created on a development branch and then deployed to production using a deploy request. Production branches are highly available and include automated daily backups. To learn more, see [How to use branches and deploy requests](#how-to-use-branches-and-deploy-requests). - -- **Referential actions and integrity.** To support scaling across multiple database servers, PlanetScale [does not allow the use of foreign key constraints](https://planetscale.com/docs/learn/operating-without-foreign-key-constraints), which are normally used in relational databases to enforce relationships between data in different tables, and asks users to handle this manually in their applications. - With Prisma you can maintain these relationships in your data and allow the use of [referential actions](/orm/prisma-schema/data-model/relations/referential-actions) by using Prisma's ability to [emulate relations in Prisma Client](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) with the `prisma` relation mode. For more information, see [How to emulate relations in Prisma Client](#how-to-emulate-relations-in-prisma-client). - -- **Creating indexes on foreign keys.** When emulating relations in Prisma, you will need to create 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. Because PlanetScale does not support foreign keys, 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 optimised. To avoid this, you can create indexes in Prisma. For more information, see [How to create indexes on foreign keys](#how-to-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'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. +- **Referential actions and integrity.** To support scaling across multiple database servers, PlanetScale [by default does not use foreign key constraints](https://planetscale.com/docs/learn/operating-without-foreign-key-constraints), which are normally used in relational databases to enforce relationships between data in different tables, and asks users to handle this manually in their applications. However, you can explicitly [enable them in the PlanetScale database settings](https://planetscale.com/docs/concepts/foreign-key-constraints). If you don't enable these explicitly, you can still maintain these relationships in your data and allow the use of [referential actions](/orm/prisma-schema/data-model/relations/referential-actions) by using Prisma ORM's ability to [emulate relations in Prisma Client](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode) with the `prisma` relation mode. For more information, see [How to emulate relations in Prisma Client](#option-1-emulate-relations-in-prisma-client). +- **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 optimised. 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. - Prisma recommends not using `prisma migrate` when making schema changes with PlanetScale. Instead, we recommend that you use the `prisma db push` command. + 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) -- **Introspection**. When you introspect on an existing database, you will get a schema with no relations, as they are usually defined based on foreign keys that connect tables. Because PlanetScale does not support foreign keys, and you use Prisma to emulate relations, you will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection). +- **Introspection**. When you introspect on an existing database and you have _not_ enabled [foreign key constraints in your PlanetScale database](#option-2-enable-foreign-key-constraints-in-the-planetscale-database-settings), you will get a schema with no relations, as they are usually defined based on foreign keys that connect tables. In that case, you will need to add the missing relations in manually. For more information, see [How to add in missing relations after Introspection](#how-to-add-in-missing-relations-after-introspection). ## How to use branches and deploy requests -When connecting to PlanetScale with Prisma, you will need to use the correct connection string for your branch. The connection URL for a given database branch can be found from your PlanetScale account by going to the overview page for the branch and selecting the 'Connect' dropdown. In the 'Passwords' section, generate a new password and select 'Prisma' from the dropdown to get the Prisma format for the connection URL. See Prisma's [Getting Started guide](/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-typescript-planetscale) for more details of how to connect to a PlanetScale database. +When connecting to PlanetScale with Prisma ORM, you will need to use the correct connection string for your branch. The connection URL for a given database branch can be found from your PlanetScale account by going to the overview page for the branch and selecting the 'Connect' dropdown. In the 'Passwords' section, generate a new password and select 'Prisma' from the dropdown to get the Prisma format for the connection URL. See Prisma ORM's [Getting Started guide](/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-typescript-planetscale) for more details of how to connect to a PlanetScale database. Every PlanetScale database is created with a branch called `main`, which is initially a development branch that you can use to test schema changes on. Once you are happy with the changes you make there, you can [promote it](https://planetscale.com/docs/concepts/branching#promote-a-branch-to-production) to become a production branch. Note that you can only push new changes to a development branch, so further changes will need to be created on a separate development branch and then later deployed to production using a [deploy request](https://planetscale.com/docs/concepts/branching#2.-create-a-deploy-request). If you try to push to a production branch, you will get the [error message](/orm/reference/error-reference#p3022) `Direct execution of DDL (Data Definition Language) SQL statements is disabled on this database.` -## How to emulate relations in Prisma Client +## How to use relations (and enable referential integrity) with PlanetScale + +### Option 1: Emulate relations in Prisma Client -PlanetScale does not allow foreign keys in its database schema. By default, Prisma uses foreign keys in the underlying database to enforce relations between fields in your Prisma schema. In Prisma versions 3.1.1 and later, you can [emulate relations in Prisma Client with the `prisma` relation mode](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode), which avoids the need for foreign keys in the database. +#### 1. Set `relationMode = "prisma"` + +PlanetScale does not use foreign key constraints in its database schema by default. However, Prisma ORM relies on foreign key constraints in the underlying database to enforce referential integrity between models in your Prisma schema. + +In Prisma ORM versions 3.1.1 and later, you can [emulate relations in Prisma Client with the `prisma` relation mode](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode), which avoids the need for foreign key constraints in the database. To enable emulation of relations in Prisma Client, set the `relationMode` field to `"prisma"` in the `datasource` block: @@ -79,15 +81,15 @@ datasource db { -The ability to set the relation mode was introduced as part of the `referentialIntegrity` preview feature in Prisma version 3.1.1, and is generally available in Prisma versions 4.8.0 and later.

The `relationMode` field was renamed in Prisma version 4.5.0, and was previously named `referentialIntegrity`. +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 `referentialIntegrity` field, PlanetScale will error when Prisma tries to create foreign keys. In versions 2.27.0 and later, Prisma will output the [P3021 error message](/orm/reference/error-reference#p3021). +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.) -## How to create indexes on foreign keys +#### 2. Create indexes on foreign keys -When [you emulate relations in Prisma Client](#how-to-emulate-relations-in-prisma-client), you need to create your own indexes. As an example of a situation where you would want to add an index, take this schema for a blog with posts and comments: +When [you emulate relations in Prisma Client](#option-1-emulate-relations-in-prisma-client), you need to create your own indexes. As an example of a situation where you would want to add an index, take this schema for a blog with posts and comments: ```prisma file=schema.prisma model Post { @@ -108,7 +110,7 @@ model Comment { The `postId` field in the `Comment` model refers to the corresponding `id` field in the `Post` model. However this is not implemented as a foreign key in PlanetScale, so the column doesn't have an automatic index. This means that some queries may not be well optimised. For example, if you query for all comments with a certain post `id`, PlanetScale may have to do a full table lookup. This could be slow, and also expensive because PlanetScale's billing model charges for the number of rows read. -To avoid this, you can define an index on the `postId` field using [Prisma's `@@index` argument](/orm/reference/prisma-schema-reference#index): +To avoid this, you can define an index on the `postId` field using [Prisma ORM's `@@index` argument](/orm/reference/prisma-schema-reference#index): ```prisma file=schema.prisma highlight=15;add model Post { @@ -131,7 +133,7 @@ model Comment { You can then add this change to your schema [using `db push`](#how-to-make-schema-changes-with-db-push). -In Prisma versions 4.7.0 and later, Prisma 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). +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). @@ -139,9 +141,41 @@ One issue to be aware of is that [implicit many-to-many relations](/orm/prisma-s +### Option 2: Enable foreign key constraints in the PlanetScale database settings + +Support for foreign key constraints in PlanetScale databases has been Generally Available since February 2024. Follow the instructions in the [PlanetScale documentation](https://planetscale.com/docs/concepts/foreign-key-constraints) to enable them in your database. + +You can then use Prisma ORM and define relations in your Prisma schema without the need for extra configuration. + +In that case, you can define a relation as with other database that supports foreign key constraints, for example: + +```prisma file=schema.prisma +model Post { + id Int @id @default(autoincrement()) + title String + content String + likes Int @default(0) + comments Comment[] +} + +model Comment { + id Int @id @default(autoincrement()) + comment String + postId Int + post Post @relation(fields: [postId], references: [id], onDelete: Cascade) +} +``` + +With this approach, it is _not_ necessary to: + +- set `relationMode = "prisma"` in your Prisma schema +- define additional indexes on foreign keys + +Also, introspection will automatically create relation fields in your Prisma schema because it can detect the foreign key constraints in the database. + ## How to make schema changes with db push -To use `db push` with PlanetScale, you will first need to [enable emulation of relations in Prisma Client](#how-to-emulate-relations-in-prisma-client). Pushing to your branch without referential emulation enabled will give the [error message](/orm/reference/error-reference#p3021) `Foreign keys cannot be created on this database.` +To use `db push` with PlanetScale, you will first need to [enable emulation of relations in Prisma Client](#option-1-emulate-relations-in-prisma-client). Pushing to your branch without referential emulation enabled will give the [error message](/orm/reference/error-reference#p3021) `Foreign keys cannot be created on this database.` As an example, let's say you decide to decide to add a new `excerpt` field to the blog post schema above. You will first need to [create a new development branch and connect to it](#how-to-use-branches-and-deploy-requests). @@ -175,10 +209,12 @@ npx prisma db push Once you are happy with your changes on your development branch, you can open a deploy request to deploy these to your production branch. -For more examples, see PlanetScale's tutorial on [automatic migrations with Prisma](https://planetscale.com/docs/prisma/automatic-prisma-migrations) using `db push`. +For more examples, see PlanetScale's tutorial on [automatic migrations with Prisma ORM](https://planetscale.com/docs/prisma/automatic-prisma-migrations) using `db push`. ## How to add in missing relations after Introspection +> **Note**: This section is only relevant if you use `relationMode = "prisma"` to emulate foreign key constraints with Prisma ORM. If you enabled foreign key constraints in your PlanetScale database, you can ignore this section. + After introspecting with `npx prisma db pull`, the schema you get may be missing some relations. For example, the following schema is missing a relation between the `User` and `Post` models: ```prisma file=schema.prisma @@ -223,15 +259,15 @@ model User { For a more detailed example, see the [Getting Started guide for PlanetScale](/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-planetscale). -## How to use the PlanetScale serverless driver with Prisma (Preview) +## How to use the PlanetScale serverless driver with Prisma ORM (Preview) The [PlanetScale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) provides a way of communicating with your database and executing queries over HTTP. -You can use Prisma along with the PlanetScale serverless driver using the [`@prisma/adapter-planetscale`](https://www.npmjs.com/package/@prisma/adapter-planetscale) driver adapter. The driver adapter allows you to communicate with your database over HTTP. +You can use Prisma ORM along with the PlanetScale serverless driver using the [`@prisma/adapter-planetscale`](https://www.npmjs.com/package/@prisma/adapter-planetscale) driver adapter. The driver adapter allows you to communicate with your database over HTTP. -This feature is available in Preview from Prisma versions 5.4.2 and later. +This feature is available in Preview from Prisma ORM versions 5.4.2 and later. @@ -260,7 +296,7 @@ DATABASE_URL='mysql://johndoe:strongpassword@aws.connect.psdb.cloud/clear_nights -Install the Prisma adapter for PlanetScale, PlanetScale serverless driver and `undici` packages: +Install the Prisma ORM adapter for PlanetScale, PlanetScale serverless driver and `undici` packages: ```sh npm install @prisma/adapter-planetscale @planetscale/database undici @@ -291,16 +327,16 @@ const prisma = new PrismaClient({ adapter }) You can then use Prisma Client as you normally would with full type-safety. Prisma Migrate, introspection, and Prisma Studio will continue working as before using the connection string defined in the Prisma schema. -## More on using PlanetScale with Prisma +## More on using PlanetScale with Prisma ORM -The fastest way to start using PlanetScale with Prisma is to refer to our Getting Started documentation: +The fastest way to start using PlanetScale with Prisma ORM is to refer to our Getting Started documentation: - [Start from scratch](/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-planetscale) - [Add to existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-planetscale) These tutorials will take you through the process of connecting to PlanetScale, pushing schema changes, and using Prisma Client. -For further tips on best practices when using Prisma and PlanetScale together, watch our video: +For further tips on best practices when using Prisma ORM and PlanetScale together, watch our video:
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 4c794cd5fa..72d59b577b 100644 --- a/content/200-orm/050-overview/500-databases/880-supabase.mdx +++ b/content/200-orm/050-overview/500-databases/880-supabase.mdx @@ -8,44 +8,44 @@ toc: true -This guide discusses the concepts behind using Prisma and Supabase, explains the commonalities and differences between Supabase and other database providers, and leads you through the process for configuring your application to integrate with Supabase. +This guide discusses the concepts behind using Prisma ORM and Supabase, explains the commonalities and differences between Supabase and other database providers, and leads you through the process for configuring your application to integrate with Supabase. ## What is Supabase? -[Supabase](https://supabase.com/) is a PostgreSQL hosting service and open source Firebase alternative providing all the backend features you need to build a product. Unlike Firebase, Supabase is backed by PostgreSQL which can be accessed directly using Prisma. +[Supabase](https://supabase.com/) is a PostgreSQL hosting service and open source Firebase alternative providing all the backend features you need to build a product. Unlike Firebase, Supabase is backed by PostgreSQL which can be accessed directly using Prisma ORM. To learn more about Supabase, you can check out their architecture [here](https://supabase.com/docs/guides/getting-started/architecture) and features [here](https://supabase.com/docs/guides/getting-started/features) ## Commonalities with other database providers -Many aspects of using Prisma with Supabase are just like using Prisma with any other relational database. You can still: +Many aspects of using Prisma ORM with Supabase are just like using Prisma ORM with any other relational database. You can still: - model your database with the [Prisma Schema Language](/orm/prisma-schema) -- use Prisma's existing [`postgresql` database connector](/orm/overview/databases/postgresql) in your schema, along with the [connection string Supabase provides you](https://supabase.com/docs/guides/database/connecting-to-postgres#finding-your-connection-string) +- use Prisma ORM's existing [`postgresql` database connector](/orm/overview/databases/postgresql) in your schema, along with the [connection string Supabase provides you](https://supabase.com/docs/guides/database/connecting-to-postgres#finding-your-connection-string) - use [Introspection](/orm/prisma-schema/introspection) for existing projects if you already have a database schema in Supabase - use [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) to push changes in your schema to Supabase - use [Prisma Client](/orm/prisma-client) in your application to talk to the database server at Supabase ## Specific considerations -If you'd like to use the [connection pooling feature](https://supabase.com/docs/guides/integrations/prisma#connection-pooling-with-supabase) available with Supabase, you will -need to add `pgbouncer=true` to the end of the `DATABASE_URL` environment variable used in the `datasource.url` property: +If you'd like to use the [connection pooling feature](https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pooler) available with Supabase, you will need to use the connection pooling connection string available via your [Supabase database settings](https://supabase.com/dashboard/project/_/settings/database) with `?pgbouncer=true` appended to the end of your `DATABASE_URL` environment variable: ```env file=.env -# Connect to Supabase with PgBouncer. -DATABASE_URL="postgres://postgres.__YOUR_SUPABASE_PROJECT__:__PASSWORD__@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true" +# Connect to Supabase via connection pooling with Supavisor. +DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-[aws-region].pooler.supabase.com:6543/postgres?pgbouncer=true" ``` -If you would like to use the Prisma CLI in order to perform other actions on your database (e.g. migrations) you will need to add a `DIRECT_URL` environment variable to use in the `datasource.directUrl` property so that the CLI can bypass PgBouncer: +If you would like to use the Prisma CLI in order to perform other actions on your database (e.g. migrations) you will need to add a `DIRECT_URL` environment variable to use in the `datasource.directUrl` property so that the CLI can bypass Supavisor: ```env file=.env highlight=4-5;add -# Connect to Supabase with PgBouncer. -DATABASE_URL="postgres://postgres.__YOUR_SUPABASE_PROJECT__:__PASSWORD__@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true" +# Connect to Supabase via connection pooling with Supavisor. +DATABASE_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-[aws-region].pooler.supabase.com:6543/postgres?pgbouncer=true" # Direct connection to the database. Used for migrations. -DIRECT_URL="postgres://postgres:__PASSWORD__@db.__YOUR SUPABASE_PROJECT__.supabase.co:5432/postgres" +DIRECT_URL="postgres://postgres.[your-supabase-project]:[password]@aws-0-[aws-region].pooler.supabase.com:5432/postgres" + ``` You can then update your `schema.prisma` to use the new direct URL: @@ -62,7 +62,7 @@ More information about the `directUrl` field can be found [here](/orm/reference/ -We strongly recommend using `pgbouncer` 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 deployment strategy. While this is not strictly necessary for every app, serverless solutions will inevitably require connection pooling. +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. 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 9f53f12d9c..80a2f80cb3 100644 --- a/content/200-orm/050-overview/500-databases/890-neon.mdx +++ b/content/200-orm/050-overview/500-databases/890-neon.mdx @@ -10,9 +10,9 @@ toc: true This guide explains how to: -- [Connect Prisma using Neon's connection pooling feature](#how-to-use-neons-connection-pooling) +- [Connect Prisma ORM using Neon's connection pooling feature](#how-to-use-neons-connection-pooling) - [Resolve connection timeout issues](#resolving-connection-timeouts) -- [Use Neon's serverless driver with Prisma](#how-to-use-neons-serverless-driver-with-prisma-preview) +- [Use Neon's serverless driver with Prisma ORM](#how-to-use-neons-serverless-driver-with-prisma-orm-preview) @@ -30,10 +30,10 @@ Learn more about Neon [here](https://neon.tech/docs). ## Commonalities with other database providers -Many aspects of using Prisma with Neon are just like using Prisma with any other PostgreSQL database. You can: +Many aspects of using Prisma ORM with Neon are just like using Prisma ORM with any other PostgreSQL database. You can: - model your database with the [Prisma Schema Language](/orm/prisma-schema) -- use Prisma's [`postgresql` database connector](/orm/overview/databases/postgresql) in your schema, along with the [connection string Neon provides you](https://neon.tech/docs/connect/connect-from-any-app) +- use Prisma ORM's [`postgresql` database connector](/orm/overview/databases/postgresql) in your schema, along with the [connection string Neon provides you](https://neon.tech/docs/connect/connect-from-any-app) - use [Introspection](/orm/prisma-schema/introspection) for existing projects if you already have a database schema on Neon - use [`prisma migrate dev`](/orm/prisma-migrate/workflows/development-and-production) to track schema migrations in your Neon database - use [`prisma db push`](/orm/prisma-migrate/workflows/prototyping-your-schema) to push changes in your schema to Neon @@ -41,7 +41,7 @@ Many aspects of using Prisma with Neon are just like using Prisma with any other ## Differences to consider -There are a few differences between Neon and PostgreSQL you should be aware of the following when deciding to use Neon with Prisma: +There are a few differences between Neon and PostgreSQL you should be aware of the following when deciding to use Neon with Prisma ORM: - **Neon's serverless model** — By default, Neon scales a [compute](https://neon.tech/docs/introduction/compute-lifecycle) to zero after 5 minutes of inactivity. During this state, a compute instance is in _idle_ state. A characteristic of this feature is the concept of a "cold start". Activating a compute from an idle state takes from 500ms to a few seconds. Depending on how long it takes to connect to your database, your application may timeout. To learn more, see: [Connection latency and timeouts](https://neon.tech/docs/guides/prisma#connection-timeouts). - **Neon's connection pooler** — Neon offers connection pooling using PgBouncer, enabling up to 10,000 concurrent connections. To learn more, see: [Connection pooling](https://neon.tech/docs/connect/connection-pooling). @@ -86,7 +86,7 @@ We strongly recommend using the pooled connection string in your `DATABASE_URL` ## Resolving connection timeouts -A connection timeout that occurs when connecting from Prisma to Neon causes an error similar to the following: +A connection timeout that occurs when connecting from Prisma ORM to Neon causes an error similar to the following: ```text no-copy Error: P1001: Can't reach database server at `ep-white-thunder-826300.us-east-2.aws.neon.tech`:`5432` @@ -97,7 +97,7 @@ This error most likely means that the connection created by Prisma Client timed A Neon compute has two main states: _Active_ and _Idle_. Active means that the compute is currently running. If there is no query activity for 5 minutes, Neon places a compute into an idle state by default. Refer to Neon's docs to [learn more](https://neon.tech/docs/introduction/compute-lifecycle). -When you connect to an idle compute from Prisma, Neon automatically activates it. Activation typically happens within a few seconds but added latency can result in a connection timeout. To address this issue, your can adjust your Neon connection string by adding a `connect_timeout` parameter. This parameter defines the maximum number of seconds to wait for a new connection to be opened. The default value is 5 seconds. A higher setting should provide the time required to avoid connection timeout issues. For example: +When you connect to an idle compute from Prisma ORM, Neon automatically activates it. Activation typically happens within a few seconds but added latency can result in a connection timeout. To address this issue, your can adjust your Neon connection string by adding a `connect_timeout` parameter. This parameter defines the maximum number of seconds to wait for a new connection to be opened. The default value is 5 seconds. A higher setting should provide the time required to avoid connection timeout issues. For example: ```text wrap DATABASE_URL=postgres://daniel:@ep-mute-rain-952417.us-east-2.aws.neon.tech/neondb?connect_timeout=10 @@ -109,21 +109,21 @@ A `connect_timeout` setting of 0 means no timeout. -Another possible cause of connection timeouts is Prisma's [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool), which has a default timeout of 10 seconds. This is typically enough time for Neon, but if you are still experiencing connection timeouts, you can try increasing this limit (in addition to the `connect_timeout` setting described above) by setting the `pool_timeout` parameter to a higher value. For example: +Another possible cause of connection timeouts is Prisma ORM's [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool), which has a default timeout of 10 seconds. This is typically enough time for Neon, but if you are still experiencing connection timeouts, you can try increasing this limit (in addition to the `connect_timeout` setting described above) by setting the `pool_timeout` parameter to a higher value. For example: ```text wrap DATABASE_URL=postgres://daniel:@ep-mute-rain-952417.us-east-2.aws.neon.tech/neondb?connect_timeout=15&pool_timeout=15 ``` -## How to use Neon's serverless driver with Prisma (Preview) +## How to use Neon's serverless driver with Prisma ORM (Preview) The [Neon serverless driver](https://github.com/neondatabase/serverless) is a low-latency Postgres driver for JavaScript and TypeScript that allows you to query data from serverless and edge environments over HTTP or WebSockets in place of TCP. -You can use Prisma along with the Neon serverless driver using a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) . A driver adapter allows you to use a different database driver from the default Prisma provides to communicate with your database. +You can use Prisma ORM along with the Neon serverless driver using a [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) . A driver adapter allows you to use a different database driver from the default Prisma ORM provides to communicate with your database. -This feature is available in Preview from Prisma versions 5.4.2 and later. +This feature is available in Preview from Prisma ORM versions 5.4.2 and later. @@ -147,7 +147,7 @@ Generate Prisma Client: npx prisma generate ``` -Install the Prisma adapter for Neon, Neon serverless driver and `ws` packages: +Install the Prisma ORM adapter for Neon, Neon serverless driver and `ws` packages: ```sh npm install @prisma/adapter-neon @neondatabase/serverless ws 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 9b7527a6cd..b1e11f62e2 100644 --- a/content/200-orm/050-overview/500-databases/900-turso.mdx +++ b/content/200-orm/050-overview/500-databases/900-turso.mdx @@ -7,9 +7,9 @@ tocDepth: 3 -This guide discusses the concepts behind using Prisma and Turso, explains the commonalities and differences between Turso and other database providers, and leads you through the process for configuring your application to integrate with Turso. +This guide discusses the concepts behind using Prisma ORM and Turso, explains the commonalities and differences between Turso and other database providers, and leads you through the process for configuring your application to integrate with Turso. -Prisma support for Turso is currently in [Early Access](/orm/more/releases#early-access). We would appreciate your feedback in this [GitHub discussion](https://github.com/prisma/prisma/discussions/21345). +Prisma ORM support for Turso is currently in [Early Access](/orm/more/releases#early-access). We would appreciate your feedback in this [GitHub discussion](https://github.com/prisma/prisma/discussions/21345). @@ -25,7 +25,7 @@ Prisma support for Turso is currently in [Early Access](/orm/more/releases#early -Support for Turso is available in [Early Access](/orm/more/releases#early-access) from Prisma versions 5.4.2 and later. +Support for Turso is available in [Early Access](/orm/more/releases#early-access) from Prisma ORM versions 5.4.2 and later. @@ -41,15 +41,15 @@ libSQL is 100% compatible with SQLite. libSQL extends SQLite and adds the follow > To learn more about the differences between libSQL and how it is different from SQLite, see [libSQL Manifesto](https://turso.tech/libsql-manifesto). -Many aspects of using Prisma with Turso are just like using Prisma with any other relational database. You can still: +Many aspects of using Prisma ORM with Turso are just like using Prisma ORM with any other relational database. You can still: - model your database with the [Prisma Schema Language](/orm/prisma-schema) -- use Prisma's existing [`sqlite` database connector](/orm/overview/databases/sqlite) in your schema +- use Prisma ORM's existing [`sqlite` database connector](/orm/overview/databases/sqlite) in your schema - use [Prisma Client](/orm/prisma-client) in your application to talk to the database server at Turso ## Differences to consider -There are a number of differences between Turso and SQLite to consider. You should be aware of the following when deciding to use Turso and Prisma: +There are a number of differences between Turso and SQLite to consider. You should be aware of the following when deciding to use Turso and Prisma ORM: - **Remote and embedded SQLite databases**. libSQL uses HTTP to connect to the remote SQLite database. libSQL also supports remote database replicas and embedded replicas. Embedded replicas enable you to replicate your primary database inside your application. - **Making schema changes**. Since libSQL uses HTTP to connect to the remote database, this makes it incompatible with Prisma Migrate. However, you can use [`prisma migrate diff`](/orm/reference/prisma-cli-reference#migrate-diff) to create a schema migration and then apply the changes to your database using [Turso's CLI](https://docs.turso.tech/reference/turso-cli). @@ -115,7 +115,7 @@ Generate Prisma Client: npx prisma generate ``` -Install the libSQL database client and Prisma driver adapter for libSQL packages: +Install the libSQL database client and Prisma ORM driver adapter for libSQL packages: ```terminal npm install @libsql/client @prisma/adapter-libsql @@ -197,7 +197,7 @@ Your application's data needs will determine how often you should synchronize da ### How to synchronize data between your remote database and embedded replica -To get started using embedded replicas with Prisma, add the `sync()` method from libSQL in your application. The example below shows how you can synchronize data using Express middleware. +To get started using embedded replicas with Prisma ORM, add the `sync()` method from libSQL in your application. The example below shows how you can synchronize data using Express middleware. ```ts highlight=5-8;add; import express from 'express' diff --git a/content/200-orm/050-overview/500-databases/index.mdx b/content/200-orm/050-overview/500-databases/index.mdx index 81680e00f6..a1cd455d1f 100644 --- a/content/200-orm/050-overview/500-databases/index.mdx +++ b/content/200-orm/050-overview/500-databases/index.mdx @@ -7,7 +7,7 @@ toc: false -Learn about the different databases Prisma supports. +Learn about the different databases Prisma ORM supports. diff --git a/content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx b/content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx index 7ff9a664d8..fc97d81577 100644 --- a/content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx +++ b/content/200-orm/100-prisma-schema/10-overview/02-data-sources.mdx @@ -6,7 +6,7 @@ metaDescription: 'Data sources enable Prisma to connect to your database. This p -A data source determines how Prisma connects your database, and is represented by the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block in the Prisma schema. The following data source uses the `postgresql` provider and includes a connection URL: +A data source determines how Prisma ORM connects your database, and is represented by the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block in the Prisma schema. The following data source uses the `postgresql` provider and includes a connection URL: ```prisma datasource db { @@ -32,7 +32,7 @@ Some data source `provider`s allow you to configure your connection with SSL/TLS - [Configuring an SSL connection with MySQL](/orm/overview/databases/mysql#configuring-an-ssl-connection) - [Configure a TLS connection with Microsoft SQL Server](/orm/overview/databases/sql-server#connection-details) -Prisma resolves SSL certificates relative to the `./prisma` directory. If your certificate files are located outside that directory, e.g. your project root directory, use relative paths for certificates: +Prisma ORM resolves SSL certificates relative to the `./prisma` directory. If your certificate files are located outside that directory, e.g. your project root directory, use relative paths for certificates: ```prisma datasource db { diff --git a/content/200-orm/100-prisma-schema/10-overview/03-generators.mdx b/content/200-orm/100-prisma-schema/10-overview/03-generators.mdx index c7190aef04..c0cfe67a50 100644 --- a/content/200-orm/100-prisma-schema/10-overview/03-generators.mdx +++ b/content/200-orm/100-prisma-schema/10-overview/03-generators.mdx @@ -36,13 +36,13 @@ generator client { ### Binary targets -Prisma Client JS (`prisma-client-js`) uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma in the form of executable, platform dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s). +Prisma Client JS (`prisma-client-js`) uses several [engines](https://github.com/prisma/prisma-engines). Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s). The correct file is particularly important when [deploying](/orm/prisma-client/deployment/deploy-prisma) your application to production, which often differs from your local development environment. #### The `native` binary target -The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma detects the _current_ operating system and automatically specifies the correct binary target for it. +The `native` binary target is special. It doesn't map to a concrete operating system. Instead, when `native` is specified in `binaryTargets`, Prisma Client detects the _current_ operating system and automatically specifies the correct binary target for it. As an example, assume you're running **macOS** and you specify the following generator: @@ -53,7 +53,7 @@ generator client { } ``` -In that case, Prisma detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) . +In that case, Prisma Client detects your operating system and finds the right binary file for it based on the [list of supported operating systems](/orm/reference/prisma-schema-reference#binarytargets-options) . If you use macOS Intel x86 (`darwin`), then the binary file that was compiled for `darwin` will be selected. If you use macOS ARM64 (`darwin-arm64`), then the binary file that was compiled for `darwin-arm64` will be selected. 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 5fd18d05bb..d8d0077941 100644 --- a/content/200-orm/100-prisma-schema/10-overview/index.mdx +++ b/content/200-orm/100-prisma-schema/10-overview/index.mdx @@ -6,9 +6,9 @@ metaDescription: 'The Prisma schema is the main configuration file when using Pr -The Prisma schema file (short: _schema file_, _Prisma schema_ or _schema_) is the main configuration file for your Prisma setup. It is typically called `schema.prisma` and consists of the following parts: +The Prisma schema file (short: _schema file_, _Prisma schema_ or _schema_) is the main configuration file for your Prisma ORM setup. It is typically called `schema.prisma` and consists of the following parts: -- [**Data sources**](data-sources): Specify the details of the data sources Prisma should connect to (e.g. a PostgreSQL database) +- [**Data sources**](data-sources): Specify the details of the data sources Prisma ORM should connect to (e.g. a PostgreSQL database) - [**Generators**](generators): Specifies what clients should be generated based on the data model (e.g. Prisma Client) - [**Data model definition**](/orm/prisma-schema/data-model): Specifies your application [models](/orm/prisma-schema/data-model/models#defining-models) (the shape of the data per data source) and their [relations](/orm/prisma-schema/data-model/relations) @@ -127,7 +127,7 @@ The schema file is written in Prisma Schema Language (PSL). ### VS Code -Syntax highlighting for PSL is available via a [VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) (which also lets you auto-format the contents of your Prisma schema and indicates syntax errors with red squiggly lines). Learn more about [setting up Prisma in your editor](/orm/more/development-environment/editor-setup). +Syntax highlighting for PSL is available via a [VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) (which also lets you auto-format the contents of your Prisma schema and indicates syntax errors with red squiggly lines). Learn more about [setting up Prisma ORM in your editor](/orm/more/development-environment/editor-setup). ### GitHub @@ -230,7 +230,7 @@ model Customer {} ## Auto formatting -Prisma supports formatting `.prisma` files automatically. There are two ways to format `.prisma` files: +Prisma ORM supports formatting `.prisma` files automatically. There are two ways to format `.prisma` files: - Run the [`prisma format`](/orm/reference/prisma-cli-reference#format) command. - Install the [Prisma VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) and invoke the [VS Code format action](https://code.visualstudio.com/docs/editor/codebasics#_formatting) - manually or on save. 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 9f21cb3958..e13e55d298 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 @@ -291,7 +291,7 @@ model Comment { } ``` -With this model definition, Prisma automatically maps the `Comment` model to the `comments` table in the underlying database. +With this model definition, Prisma ORM automatically maps the `Comment` model to the `comments` table in the underlying database. > **Note**: You can also [`@map`](/orm/reference/prisma-schema-reference#map) a column name or enum value, and `@@map` an enum name. @@ -395,7 +395,7 @@ model Post { model Comment { id Int // Other fields - Post Post? @relation(fields: [postId], references: [id]) // A comment can have one post + post Post? @relation(fields: [postId], references: [id]) // A comment can have one post postId Int? } ``` @@ -413,7 +413,7 @@ model Post { model Comment { id String @id @default(auto()) @map("_id") @db.Objectid // Other fields - Post Post? @relation(fields: [postId], references: [id]) // A comment can have one post + post Post? @relation(fields: [postId], references: [id]) // A comment can have one post postId String? @db.ObjectId } ``` @@ -490,7 +490,7 @@ model Post { -> **Note**: Scalar lists are **only** supported if the database connector supports scalar lists, either natively or at a Prisma level. +> **Note**: Scalar lists are **only** supported if the database connector supports scalar lists, either natively or at a Prisma ORM level. #### Optional and mandatory fields @@ -544,9 +544,9 @@ When you introspect a relational database, unsupported data types are added as [ location Unsupported("POLYGON")? ``` -The `Unsupported` type allows you to define fields in the Prisma schema for database types that are not yet supported by Prisma. For example, MySQL's `POLYGON` type is not currently supported by Prisma, but can now be added to the Prisma schema using the `Unsupported("POLYGON")` type. +The `Unsupported` type allows you to define fields in the Prisma schema for database types that are not yet supported by Prisma ORM. For example, MySQL's `POLYGON` type is not currently supported by Prisma ORM, but can now be added to the Prisma schema using the `Unsupported("POLYGON")` type. -Fields of type `Unsupported` are not available in the generated Prisma Client API, but you can still use Prisma's [raw database access](/orm/prisma-client/queries/raw-database-access/raw-queries) feature to query these fields. +Fields of type `Unsupported` are not available in the generated Prisma Client API, but you can still use Prisma ORM's [raw database access](/orm/prisma-client/queries/raw-database-access/raw-queries) feature to query these fields. > **Note**: If a model has **mandatory `Unsupported` fields**, the generated client will not include `create` or `update` methods for that model. @@ -663,7 +663,7 @@ Refer to the documentation on [working with composite IDs](/orm/prisma-client/sp ##### @unique fields as unique identifiers -In the following example, users are uniquely identified by a `@unique` field. Because the `email` field functions as a unique identifier for the model (which is required by Prisma), it must be mandatory: +In the following example, users are uniquely identified by a `@unique` field. Because the `email` field functions as a unique identifier for the model (which is required), it must be mandatory: ```prisma highlight=2;normal model User { @@ -759,12 +759,12 @@ model Post { `@default` attributes either: - Represent `DEFAULT` values in the underlying database (relational databases only) _or_ -- Use a Prisma-level function. For example, `cuid()` and `uuid()` are provided by Prisma's [query engine](/orm/more/under-the-hood/engines) for all connectors. +- Use a Prisma ORM-level function. For example, `cuid()` and `uuid()` are provided by Prisma Client's [query engine](/orm/more/under-the-hood/engines) for all connectors. Default values can be: - Static values that correspond to the field type, such as `5` (`Int`), `Hello` (`String`), or `false` (`Boolean`) -- [Lists](/orm/reference/prisma-schema-reference#-modifier) of static values, such as `[5, 6, 8]` (`Int[]`) or `["Hello", "Goodbye"]` (`String`[]). These are available in versions `4.0.0` and later, when using databases where Prisma supports them (PostgreSQL, CockroachDB and MongoDB) +- [Lists](/orm/reference/prisma-schema-reference#-modifier) of static values, such as `[5, 6, 8]` (`Int[]`) or `["Hello", "Goodbye"]` (`String`[]). These are available in Prisma ORM versions `4.0.0` and later, when using supported databases (PostgreSQL, CockroachDB and MongoDB) - [Functions](#using-functions), such as [`now()`](/orm/reference/prisma-schema-reference#now) or [`uuid()`](/orm/reference/prisma-schema-reference#uuid) @@ -981,9 +981,9 @@ model User { ## Defining enums -You can define enums in your data model [if enums are supported for your database connector](/orm/reference/database-features#misc), either natively or at Prisma level. +You can define enums in your data model [if enums are supported for your database connector](/orm/reference/database-features#misc), either natively or at Prisma ORM level. -Enums are considered [scalar](#scalar-fields) types in the Prisma data model. They're therefore [by default](/orm/prisma-client/queries/select-fields#return-the-default-selection-set) included as return values in [Prisma Client queries](/orm/prisma-client/queries/crud). +Enums are considered [scalar](#scalar-fields) types in the Prisma schema data model. They're therefore [by default](/orm/prisma-client/queries/select-fields#return-the-default-selection-set) included as return values in [Prisma Client queries](/orm/prisma-client/queries/crud). Enums are defined via the [`enum`](/orm/reference/prisma-schema-reference#enum) block. For example, a `User` has a `Role`: @@ -1107,11 +1107,11 @@ model Post { -[`cuid()`](/orm/reference/prisma-schema-reference#cuid) and [`uuid()`](/orm/reference/prisma-schema-reference#uuid) are implemented by Prisma and therefore are not "visible" in the underlying database schema. You can still use them when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma's [query engine](/orm/more/under-the-hood/engines) +[`cuid()`](/orm/reference/prisma-schema-reference#cuid) and [`uuid()`](/orm/reference/prisma-schema-reference#uuid) are implemented by Prisma ORM and therefore are not "visible" in the underlying database schema. You can still use them when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma Client's [query engine](/orm/more/under-the-hood/engines) Support for [`autoincrement()`](/orm/reference/prisma-schema-reference#autoincrement) , [`now()`](/orm/reference/prisma-schema-reference#now) and [`dbgenerated()`](/orm/reference/prisma-schema-reference#dbgenerated) differ between databases. -**Relational database connectors** implement `autoincrement()`, `dbgenerated()`, and `now()` at database level. The **MongoDB connector** does not support `autoincrement()` or `dbgenerated()`, and `now()` is implemented at Prisma level. The [`auto()`](/orm/reference/prisma-schema-reference#auto) function is used to generate an `ObjectId`. +**Relational database connectors** implement `autoincrement()`, `dbgenerated()`, and `now()` at database level. The **MongoDB connector** does not support `autoincrement()` or `dbgenerated()`, and `now()` is implemented at Prisma ORM level. The [`auto()`](/orm/reference/prisma-schema-reference#auto) function is used to generate an `ObjectId`. ## Relations @@ -1176,7 +1176,7 @@ Note that the relation fields `posts` and `profile` are not included in the type ### Records must be uniquely identifiable -Prisma currently only supports models that have at least one unique field or combination of fields. In practice, this means that every Prisma model must have either at least one of the following attributes: +Prisma ORM currently only supports models that have at least one unique field or combination of fields. In practice, this means that every Prisma model must have either at least one of the following attributes: - `@id` or `@@id` for a single- or multi-field primary key constraint (max one per model) - `@unique` or `@@unique` for a single- or multi-field unique constraint 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 35ac1c56c5..1cbd1d44c8 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 @@ -95,7 +95,7 @@ model Profile { -In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma 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. +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. @@ -168,7 +168,7 @@ CREATE TABLE "Profile" ( ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following MongoDB document represents a `User`: 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 62b1169d76..132a29409e 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 @@ -97,7 +97,7 @@ model Post { -In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma 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. +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. @@ -171,7 +171,7 @@ In relational databases, the main difference between a 1-1 and a 1-n-relation is ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following MongoDB document represents a `User`: 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 89499c2ab9..6b3f9c96b9 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 @@ -84,7 +84,7 @@ ALTER TABLE "CategoriesOnPosts" ADD CONSTRAINT "CategoriesOnPosts_categoryId_fke Note that the same rules as for [1-n relations](one-to-many-relations) apply (because `Post`↔ `CategoriesOnPosts` and `Category` ↔ `CategoriesOnPosts` are both in fact 1-n relations), which means one side of the relation needs to be annotated with the `@relation` attribute. -When you don't need to attach additional information to the relation, you can model m-n-relations as [implicit m-n-relations](#implicit-many-to-many-relations). If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit m-n-relations by following Prisma's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations). +When you don't need to attach additional information to the relation, you can model m-n-relations as [implicit m-n-relations](#implicit-many-to-many-relations). If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit m-n-relations by following Prisma ORM's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations). #### Querying an explicit many-to-many @@ -238,7 +238,7 @@ const getAssignments = await prisma.categoriesOnPosts.findMany({ ### Implicit many-to-many relations -Implicit m-n relations define relation fields as lists on both sides of the relation. Although the relation table exists in the underlying database, **it is managed by Prisma and does not manifest in the Prisma schema**. Implicit relation tables follow a [specific convention](#conventions-for-relation-tables-in-implicit-m-n-relations). +Implicit m-n relations define relation fields as lists on both sides of the relation. Although the relation table exists in the underlying database, **it is managed by Prisma ORM and does not manifest in the Prisma schema**. Implicit relation tables follow a [specific convention](#conventions-for-relation-tables-in-implicit-m-n-relations). Implicit m-n-relations makes the [Prisma Client API](/orm/prisma-client) for m-n-relations a bit simpler (since you have one fewer level of nesting inside of [nested writes](/orm/prisma-client/queries/relation-queries#nested-writes)). @@ -348,7 +348,7 @@ Implicit m-n relations: #### Conventions for relation tables in implicit m-n relations -If you obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still use implicit m-n-relations by following Prisma's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations). The following example assumes you want to create a relation table to get an implicit m-n-relation for two models called `Post` and `Category`. +If you obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still use implicit m-n-relations by following Prisma ORM's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations). The following example assumes you want to create a relation table to get an implicit m-n-relation for two models called `Post` and `Category`. ##### Relation table @@ -458,7 +458,7 @@ model Video { #### Configuring the name of the relation table in implicit many-to-many relations -When using Prisma Migrate, you can configure the name of the relation table that's managed by Prisma using the `@relation` attribute. For example, if you want the relation table to be called `_MyRelationTable` instead of the default name `_CategoryToPost`, you can specify it as follows: +When using Prisma Migrate, you can configure the name of the relation table that's managed by Prisma ORM using the `@relation` attribute. For example, if you want the relation table to be called `_MyRelationTable` instead of the default name `_CategoryToPost`, you can specify it as follows: ```prisma model Post { @@ -476,7 +476,7 @@ model Category { A relation table (also sometimes called a _JOIN_, _link_ or _pivot_ table) connects two or more other tables and therefore creates a _relation_ between them. Creating relation tables is a common data modelling practice in SQL to represent relationships between different entities. In essence it means that "one m-n relation is modeled as two 1-n relations in the database". -We recommend using [implicit](#implicit-many-to-many-relations) m-n-relations, where Prisma automatically generates the relation table in the underlying database. [Explicit](#explicit-many-to-many-relations) m-n-relations should be used when you need to store additional data in the relations, such as the date the relation was created. +We recommend using [implicit](#implicit-many-to-many-relations) m-n-relations, where Prisma ORM automatically generates the relation table in the underlying database. [Explicit](#explicit-many-to-many-relations) m-n-relations should be used when you need to store additional data in the relations, such as the date the relation was created. ## MongoDB @@ -502,7 +502,7 @@ model Category { } ``` -Prisma validates m-n-relations in MongoDB with the following rules: +Prisma ORM validates m-n-relations in MongoDB with the following rules: - The fields on both sides of the relation must have a list type (in the example above, `categories` have a type of `Category[]` and `posts` have a type of `Post[]`) - The `@relation` attribute must define `fields` and `references` arguments on both sides diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/400-self-relations.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/400-self-relations.mdx index 158e941dc1..d710a34339 100644 --- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/400-self-relations.mdx +++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/400-self-relations.mdx @@ -169,7 +169,7 @@ ALTER TABLE "User" ADD CONSTRAINT successor_unique UNIQUE ("successorId"); ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following MongoDB documents represent a one-to-one self-relation between two users: @@ -245,7 +245,7 @@ Notice the lack of `UNIQUE` constraint on `teacherId` - multiple students can ha ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following MongoDB documents represent a one-to-many self-relation between three users - one teacher and two students with the same `teacherId`: @@ -310,7 +310,7 @@ This relation expresses the following: - "a user can be followed by zero or more users" - "a user can follow zero or more users" -Note that for relational databases, this many-to-many-relation is [implicit](many-to-many-relations#implicit-many-to-many-relations). This means Prisma maintains a [relation table](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) for it in the underlying database. +Note that for relational databases, this many-to-many-relation is [implicit](many-to-many-relations#implicit-many-to-many-relations). This means Prisma ORM maintains a [relation table](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) for it in the underlying database. If you need the relation to hold other fields, you can create an [explicit](many-to-many-relations#explicit-many-to-many-relations) many-to-many self relation as well. The explicit version of the self relation shown previously is as follows: @@ -378,7 +378,7 @@ CREATE TABLE "_UserFollows" ( ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following MongoDB documents represent a many-to-many self-relation between five users - two users that follow `"Bob"`, and two users that follow him: diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/100-special-rules-for-referential-actions.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/100-special-rules-for-referential-actions.mdx index 64174bd2c9..49e111adef 100644 --- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/100-special-rules-for-referential-actions.mdx +++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/410-referential-actions/100-special-rules-for-referential-actions.mdx @@ -9,9 +9,9 @@ tocDepth: 3 Some databases have specific requirements that you should consider if you are using referential actions. -- Microsoft SQL Server doesn't allow cascading referential actions on a foreign key, if the relation chain causes a cycle or multiple cascade paths. If the referential actions on the foreign key are set to something other than `NO ACTION` (or `NoAction` if Prisma is managing referential integrity), the server will check for cycles or multiple cascade paths and return an error when executing the SQL. +- Microsoft SQL Server doesn't allow cascading referential actions on a foreign key, if the relation chain causes a cycle or multiple cascade paths. If the referential actions on the foreign key are set to something other than `NO ACTION` (or `NoAction` if Prisma ORM is managing referential integrity), the server will check for cycles or multiple cascade paths and return an error when executing the SQL. -- With MongoDB, using referential actions in Prisma requires that for any data model with self-referential relations or cycles between three models, you must set the referential action of `NoAction` to prevent the referential action emulations from looping infinitely. Be aware that by default, the `relationMode = "prisma"` mode is used for MongoDB, which means that Prisma manages [referential integrity](/orm/prisma-schema/data-model/relations/relation-mode). +- With MongoDB, using referential actions in Prisma ORM requires that for any data model with self-referential relations or cycles between three models, you must set the referential action of `NoAction` to prevent the referential action emulations from looping infinitely. Be aware that by default, the `relationMode = "prisma"` mode is used for MongoDB, which means that Prisma ORM manages [referential integrity](/orm/prisma-schema/data-model/relations/relation-mode). Given the SQL: @@ -34,7 +34,7 @@ When the SQL is run, the database would throw the following error: Introducing FOREIGN KEY constraint 'FK__Employee__managerId' on table 'Employee' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. ``` -In more complicated data models, finding the cascade paths can get complex. Therefore in Prisma, the data model is validated _before_ generating any SQL to be run during any migrations, highlighting relations that are part of the paths. This makes it much easier to find and break these action chains. +In more complicated data models, finding the cascade paths can get complex. Therefore in Prisma ORM, the data model is validated _before_ generating any SQL to be run during any migrations, highlighting relations that are part of the paths. This makes it much easier to find and break these action chains. @@ -57,7 +57,7 @@ This will result in the following error: Error parsing attribute "@relation": A self-relation must have `onDelete` and `onUpdate` referential actions set to `NoAction` in one of the @relation attributes. (Implicit default `onDelete`: `SetNull`, and `onUpdate`: `Cascade`) ``` -By not defining any actions, Prisma will use the following default values depending if the underlying [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields) are set to be optional or required. +By not defining any actions, Prisma ORM will use the following default values depending if the underlying [scalar fields](/orm/prisma-schema/data-model/models#scalar-fields) are set to be optional or required. | Clause | All of the scalar fields are optional | At least one scalar field is required | | :--------- | :------------------------------------ | :------------------------------------ | 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 df02fa24e0..c895a0e668 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 @@ -9,7 +9,7 @@ tocDepth: 3 Referential actions determine what happens to a record when your application deletes or updates a related record. -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 level. +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. @@ -37,14 +37,14 @@ model User { } ``` -If you do not specify a referential action, Prisma [uses a default](#referential-action-defaults). +If you do not specify a referential action, Prisma ORM [uses a default](#referential-action-defaults). 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 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-2x-default-referential-actions) - `ON DELETE CASCADE` - becomes active. This might result in cascading deletes that you did not expect. +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. @@ -66,7 +66,7 @@ By default a database will reject any operation that violates the referential in ### How to use referential actions -Referential actions are defined in the [`@relation`](/orm/reference/prisma-schema-reference#relation) attribute and map to the actions on the **foreign key constraint** in the underlying database. If you do not specify a referential action, [Prisma falls back to a default](#referential-action-defaults). +Referential actions are defined in the [`@relation`](/orm/reference/prisma-schema-reference#relation) attribute and map to the actions on the **foreign key constraint** in the underlying database. If you do not specify a referential action, [Prisma ORM falls back to a default](#referential-action-defaults). The following model defines a one-to-many relation between `User` and `Post` and a many-to-many relation between `Post` and `Tag`, with explicitly defined referential actions: @@ -104,7 +104,7 @@ This model explicitly defines the following referential actions: - If you delete a `Tag`, the corresponding tag assignment is also deleted in `TagOnPosts`, using the `Cascade` referential action - If you delete a `User`, the author is removed from all posts by setting the field value to `Null`, because of the `SetNull` referential action. To allow this, `User` and `userId` must be optional fields in `Post`. -Prisma supports the following referential actions: +Prisma ORM supports the following referential actions: - [`Cascade`](#cascade) - [`Restrict`](#restrict) @@ -114,7 +114,7 @@ Prisma supports the following referential actions: ### Referential action defaults -If you do not specify a referential action, Prisma uses the following defaults: +If you do not specify a referential action, Prisma ORM uses the following defaults: | Clause | Optional relations | Mandatory relations | | :--------- | :----------------- | :------------------ | @@ -150,38 +150,38 @@ The following caveats apply: The following table shows which referential action each database supports. -| Database | Cascade | Restrict | NoAction | SetNull | SetDefault | -| :---------- | :------ | :------- | :------- | :------ | :--------- | -| PostgreSQL | ✔️ | ✔️ | ✔️ | ✔️⌘ | ✔️ | -| MySQL | ✔️ | ✔️ | ✔️ | ✔️ | ❌ (✔️†) | -| SQLite | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| SQL Server | ✔️ | ❌‡ | ✔️ | ✔️ | ✔️ | -| CockroachDB | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | -| MongoDB†† | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | +| Database | Cascade | Restrict | NoAction | SetNull | SetDefault | +| :------------ | :------ | :------- | :------- | :------ | :--------- | +| PostgreSQL | ✔️ | ✔️ | ✔️ | ✔️⌘ | ✔️ | +| MySQL/MariaDB | ✔️ | ✔️ | ✔️ | ✔️ | ❌ (✔️†) | +| SQLite | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| SQL Server | ✔️ | ❌‡ | ✔️ | ✔️ | ✔️ | +| CockroachDB | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +| MongoDB†† | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | - † See [special cases for MySQL](#mysql). - ⌘ See [special cases for PostgreSQL](#postgresql). - ‡ See [special cases for SQL Server](#sql-server). -- †† Referential actions for MongoDB are available in Prisma versions 3.7.0 and later. +- †† Referential actions for MongoDB are available in Prisma ORM versions 3.7.0 and later. ### Special cases for referential actions Referential actions are part of the ANSI SQL standard. However, there are special cases where some relational databases diverge from the standard. -#### MySQL +#### MySQL/MariaDB -MySQL, and the underlying InnoDB storage engine, does not support `SetDefault`. The exact behavior depends on the database version: +MySQL/MariaDB, and the underlying InnoDB storage engine, does not support `SetDefault`. The exact behavior depends on the database version: - In MySQL versions 8 and later, and MariaDB versions 10.5 and later, `SetDefault` effectively acts as an alias for `NoAction`. You can define tables using the `SET DEFAULT` referential action, but a foreign key constraint error is triggered at runtime. - In MySQL versions 5.6 and later, and MariaDB versions before 10.5, attempting to create a table definition with the `SET DEFAULT` referential action fails with a syntax error. -For this reason, when you set `mysql` as the database provider, Prisma warns users to replace `SetDefault` referential actions in the Prisma schema with another action. +For this reason, when you set `mysql` as the database provider, Prisma ORM warns users to replace `SetDefault` referential actions in the Prisma schema with another action. #### PostgreSQL -PostgreSQL is the only database supported by Prisma that allows you to define a `SetNull` referential action that refers to a non-nullable field. However, this raises a foreign key constraint error when the action is triggered at runtime. +PostgreSQL is the only database supported by Prisma ORM that allows you to define a `SetNull` referential action that refers to a non-nullable field. However, this raises a foreign key constraint error when the action is triggered at runtime. -For this reason, when you set `postgres` as the database provider in the (default) `foreignKeys` relation mode, Prisma warns users to mark as optional any fields that are included in a `@relation` attribute with a `SetNull` referential action. For all other database providers, Prisma rejects the schema with a validation error. +For this reason, when you set `postgres` as the database provider in the (default) `foreignKeys` relation mode, Prisma ORM warns users to mark as optional any fields that are included in a `@relation` attribute with a `SetNull` referential action. For all other database providers, Prisma ORM rejects the schema with a validation error. #### SQL Server @@ -269,7 +269,7 @@ The `NoAction` action is similar to `Restrict`, the difference between the two i -If you are [managing relations in Prisma Client](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-with-the-prisma-relation-mode) rather than using foreign keys in the database, you should be aware that currently Prisma 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. +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. @@ -367,7 +367,7 @@ The following assumes you have upgraded to 2.26.0 or newer and enabled the previ If you [Introspect](/orm/prisma-schema/introspection) your database, the referential actions configured at the database level will be reflected in your Prisma Schema. If you have been using Prisma Migrate or `prisma db push` to manage the database schema, these are likely to be the [default values](#referential-action-defaults) from 2.25.0 and earlier. -When you run an Introspection, Prisma compares all the foreign keys in the database with the schema, if the SQL statements `ON DELETE` and `ON UPDATE` do **not** match the default values, they will be explicitly set in the schema file. +When you run an Introspection, Prisma ORM compares all the foreign keys in the database with the schema, if the SQL statements `ON DELETE` and `ON UPDATE` do **not** match the default values, they will be explicitly set in the schema file. 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. @@ -414,15 +414,15 @@ You will have to manually add them if you wish to use anything other than the ne -Explicitly defining referential actions in your Prisma schema is optional. If you do not explicitly define a referential action for a relation, Prisma uses the [new defaults](#referential-action-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). Note that referential actions can be added on a case by case basis. This means that you can add them to one single relation and leave the rest set to the defaults by not manually specifying anything. ### Checking for errors -**Before** upgrading to 2.26.0 and enabling the referential actions **preview feature**, Prisma prevented the deletion of records while using `delete()` or `deleteMany()` to preserve referential integrity. A custom runtime error would be thrown by Prisma Client with the error code `P2014`. +**Before** upgrading to 2.26.0 and enabling the referential actions **preview feature**, Prisma ORM prevented the deletion of records while using `delete()` or `deleteMany()` to preserve referential integrity. A custom runtime error would be thrown by Prisma Client with the error code `P2014`. -**After** upgrading and enabling the referential actions **preview feature**, Prisma no longer performs runtime checks. You can instead specify a custom referential action to preserve the referential integrity between relations. +**After** upgrading and enabling the referential actions **preview feature**, Prisma ORM no longer performs runtime checks. You can instead specify a custom referential action to preserve the referential integrity between relations. When you use [`NoAction`](#noaction) or [`Restrict`](#restrict) to prevent the deletion of records, the error messages will be different post 2.26.0 compared to pre 2.26.0. This is because they are now triggered by the database and **not** Prisma Client. The new error code that can be expected is `P2003`. 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 8ff4964b82..f0d8b5e4f9 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 @@ -7,7 +7,7 @@ tocDepth: 3 -In Prisma, relations between records are defined with the [`@relation`](/orm/reference/prisma-schema-reference#relation) attribute. For example, in the following schema there is a one-to-many relation between the `User` and `Post` models: +In Prisma schema, relations between records are defined with the [`@relation`](/orm/reference/prisma-schema-reference#relation) attribute. For example, in the following schema there is a one-to-many relation between the `User` and `Post` models: ```prisma file=schema.prisma highlight=4,5,10;normal model Post { @@ -23,9 +23,9 @@ model User { } ``` -Prisma has two _relation modes_, `foreignKeys` and `prisma`, that specify how relations between records are enforced. +Prisma ORM has two _relation modes_, `foreignKeys` and `prisma`, that specify how relations between records are enforced. -If you use Prisma with a relational database, then by default Prisma uses the [`foreignKeys` relation mode](#handle-relations-in-your-relational-database-with-the-foreignkeys-relation-mode), which enforces relations between records at the database level with foreign keys. A foreign key is a column or group of columns in one table that take values based on the primary key in another table. Foreign keys allow you to: +If you use Prisma ORM with a relational database, then by default Prisma ORM uses the [`foreignKeys` relation mode](#handle-relations-in-your-relational-database-with-the-foreignkeys-relation-mode), which enforces relations between records at the database level with foreign keys. A foreign key is a column or group of columns in one table that take values based on the primary key in another table. Foreign keys allow you to: - set constraints that prevent you from making changes that break references - set [referential actions](/orm/prisma-schema/data-model/relations/referential-actions) that define how changes to records are handled @@ -61,7 +61,7 @@ ALTER TABLE "Post" In this case, the foreign key constraint on the `authorId` column of the `Post` table references the `id` column of the `User` table, and guarantees that a post must have an author that exists. If you update or delete a user then the `ON DELETE` and `ON UPDATE` referential actions specify the `CASCADE` option, which will also delete or update all posts belonging to the user. -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 offers [the `prisma` relation mode](#emulate-relations-in-prisma-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. +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. There are performance implications to emulation of referential integrity and @@ -85,20 +85,20 @@ datasource db { -The ability to set the relation mode was introduced as part of the `referentialIntegrity` preview feature in Prisma version 3.1.1, and is generally available in Prisma versions 4.8.0 and later.

The `relationMode` field was renamed in Prisma version 4.5.0, and was previously named `referentialIntegrity`. +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: - `foreignKeys`: this handles relations in the database with foreign keys. This is the default option for all relational database connectors and is active if no `relationMode` is explicitly set in the `datasource` block. -- `prisma`: this emulates relations in Prisma Client. You should also [enable this option](/orm/overview/databases/planetscale#how-to-emulate-relations-in-prisma-client) when you use the MySQL connector with a PlanetScale database. +- `prisma`: this emulates relations in Prisma Client. You should also [enable this option](/orm/overview/databases/planetscale#option-1-emulate-relations-in-prisma-client) when you use the MySQL connector with a PlanetScale database and don't have native foreign key constraints enabled in your PlanetScale database settings. 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. -If you switch between relation modes, Prisma 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. +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. @@ -106,7 +106,7 @@ If you switch between relation modes, Prisma will add or remove foreign keys to The `foreignKeys` relation mode handles relations in your relational database with foreign keys. This is the default option when you use a relational database connector (PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB). -The `foreignKeys` relation mode is not available when you use the MongoDB connector. Some relational databases, [such as PlanetScale](/orm/overview/databases/planetscale#how-to-emulate-relations-in-prisma-client), also forbid the use of foreign keys. In these cases, you should instead [emulate relations in Prisma with the `prisma` relation mode](#emulate-relations-in-prisma-with-the-prisma-relation-mode). +The `foreignKeys` relation mode is not available when you use the MongoDB connector. Some relational databases, [such as PlanetScale](/orm/overview/databases/planetscale#option-1-emulate-relations-in-prisma-client), also forbid the use of foreign keys. In these cases, you should instead [emulate relations in Prisma ORM with the `prisma` relation mode](#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode). ### Referential integrity @@ -130,11 +130,11 @@ When you introspect a relational database with the `db pull` command with the `f When you apply changes to your Prisma schema with Prisma Migrate or `db push` with the `foreignKeys` relation mode enabled, foreign keys will be created in your database for all `@relation` attributes in your schema. -## Emulate relations in Prisma with the prisma relation mode +## Emulate relations in Prisma ORM with the prisma relation mode The `prisma` relation mode emulates some foreign key constraints and referential actions for each Prisma Client query to maintain referential integrity, using some additional database queries and logic. -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#how-to-emulate-relations-in-prisma-client) you should use the `prisma` relation mode. +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. There are performance implications to emulation of referential integrity in @@ -147,13 +147,13 @@ Emulation of relations is only available for Prisma Client queries and does not ### Which foreign key constraints are emulated? -When you _update_ a record, Prisma will emulate foreign key constraints. This means that when you update a record with a relation to another record, the related record needs to exist. If the record does not exist, Prisma Client will return an error message. +When you _update_ a record, Prisma ORM will emulate foreign key constraints. This means that when you update a record with a relation to another record, the related record needs to exist. If the record does not exist, Prisma Client will return an error message. -However, when you _create_ a record, Prisma does not emulate any foreign key constraints. You will be able to create invalid data. +However, when you _create_ a record, Prisma ORM does not emulate any foreign key constraints. You will be able to create invalid data. ### Which referential actions are emulated? -When you _update_ or _delete_ a record with related records, Prisma will emulate referential actions. +When you _update_ or _delete_ a record with related records, Prisma ORM will emulate referential actions. @@ -185,11 +185,11 @@ Example: ### Introspection -When you introspect a database with the `db pull` command with the `prisma` relation mode enabled, relations will not be automatically added to your schema. You will instead need to add any relations manually with the `@relation` attribute. This only needs to be done once – next time you introspect your database, Prisma will keep your added `@relation` attributes. +When you introspect a database with the `db pull` command with the `prisma` relation mode enabled, relations will not be automatically added to your schema. You will instead need to add any relations manually with the `@relation` attribute. This only needs to be done once – next time you introspect your database, Prisma ORM will keep your added `@relation` attributes. ### Prisma Migrate and db push -When you apply changes to your Prisma schema with Prisma Migrate or `db push` with the `prisma` relation mode enabled, Prisma will not use foreign keys in your database. +When you apply changes to your Prisma schema with Prisma Migrate or `db push` with the `prisma` relation mode enabled, Prisma ORM will not use foreign keys in your database. ### Indexes @@ -199,7 +199,7 @@ The `prisma` relation mode does not use foreign keys, so no indexes are created #### Index validation -If you do not add the index manually, queries might require full table scans. This can be slow, and also expensive on database providers that bill per accessed row. To help avoid this, Prisma warns you when your schema contains fields that are used in a `@relation` that does not have an index defined. For example, take the following schema with a relation between the `User` and `Post` models: +If you do not add the index manually, queries might require full table scans. This can be slow, and also expensive on database providers that bill per accessed row. To help avoid this, Prisma ORM warns you when your schema contains fields that are used in a `@relation` that does not have an index defined. For example, take the following schema with a relation between the `User` and `Post` models: ```prisma file=schema.prisma datasource db { @@ -220,7 +220,7 @@ model Post { } ``` -Prisma displays the following warning when you run `prisma format` or `prisma validate`: +Prisma ORM displays the following warning when you run `prisma format` or `prisma validate`: ```terminal wrap With `relationMode = "prisma"`, no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to poor performance when querying these fields. We recommend adding an index manually. @@ -250,10 +250,10 @@ It is only possible to switch between relation modes when you use a relational d The default relation mode if you use a relational database and do not include the `relationMode` field in your `datasource` block is `foreignKeys`. To switch to the `prisma` relation mode, add the `relationMode` field with a value of `prisma`, or update the `relationMode` field value to `prisma` if it already exists. -When you switch the relation mode from `foreignKeys` to `prisma`, after you first apply changes to your schema with Prisma Migrate or `db push` Prisma will remove all previously created foreign keys in the next migration. +When you switch the relation mode from `foreignKeys` to `prisma`, after you first apply changes to your schema with Prisma Migrate or `db push` Prisma ORM will remove all previously created foreign keys in the next migration. If you keep the same database, you can then continue to work as normal. If you switch to a database that does not support foreign keys at all, your existing migration history contains SQL DDL that creates foreign keys, which might trigger errors if you ever have to rerun these migrations. In this case, we recommend that you delete the `migrations` directory. (If you use PlanetScale, which does not support foreign keys, we generally recommend that you [use `db push` rather than Prisma Migrate](/orm/overview/databases/planetscale#differences-to-consider).) ### Switch from prisma to foreignKeys -To switch from the `prisma` relation mode to the `foreignKeys` relation mode, update the `relationMode` field value from `prisma` to `foreignKeys`. To do this, the database must support foreign keys. When you apply changes to your schema with Prisma Migrate or `db push` for the first time after you switch relation modes, Prisma will create foreign keys for all relations in the next migration. +To switch from the `prisma` relation mode to the `foreignKeys` relation mode, update the `relationMode` field value from `prisma` to `foreignKeys`. To do this, the database must support foreign keys. When you apply changes to your schema with Prisma Migrate or `db push` for the first time after you switch relation modes, Prisma ORM will create foreign keys for all relations in the next migration. diff --git a/content/200-orm/100-prisma-schema/20-data-model/20-relations/500-troubleshooting-relations.mdx b/content/200-orm/100-prisma-schema/20-data-model/20-relations/500-troubleshooting-relations.mdx index 82ebbcc5e2..6fb1760839 100644 --- a/content/200-orm/100-prisma-schema/20-data-model/20-relations/500-troubleshooting-relations.mdx +++ b/content/200-orm/100-prisma-schema/20-data-model/20-relations/500-troubleshooting-relations.mdx @@ -139,9 +139,9 @@ If you rename relation fields in an implicit many-to-many self-relations, make s ## How to use a relation table with a many-to-many relationship -There are a couple of ways to define a m-n relationship, implicitly or explicitly. Implicitly means letting Prisma handle the relation table (JOIN table) under the hood, all you have to do is define an array/list for the non scalar types on each model, see [implicit many-to-many relations](many-to-many-relations#implicit-many-to-many-relations). +There are a couple of ways to define a m-n relationship, implicitly or explicitly. Implicitly means letting Prisma ORM handle the relation table (JOIN table) under the hood, all you have to do is define an array/list for the non scalar types on each model, see [implicit many-to-many relations](many-to-many-relations#implicit-many-to-many-relations). -Where you might run into trouble is when creating an [explicit m-n relationship](many-to-many-relations#explicit-many-to-many-relations), that is, to create and handle the relation table yourself. **It can be overlooked that Prisma requires both sides of the relation to be present**. +Where you might run into trouble is when creating an [explicit m-n relationship](many-to-many-relations#explicit-many-to-many-relations), that is, to create and handle the relation table yourself. **It can be overlooked that Prisma ORM requires both sides of the relation to be present**. Take the following example, here a relation table is created to act as the JOIN between the `Post` and `Category` tables. This will not work however as the relation table (`PostCategories`) must form a 1-to-many relationship with the other two models respectively. @@ -224,7 +224,7 @@ model Category { } ``` -This however tells Prisma to expect **two** separate one-to-many relationships. See [disambiguating relations](/orm/prisma-schema/data-model/relations#disambiguating-relations) for more information on using the `@relation` attribute. +This however tells Prisma ORM to expect **two** separate one-to-many relationships. See [disambiguating relations](/orm/prisma-schema/data-model/relations#disambiguating-relations) for more information on using the `@relation` attribute. The following example is the correct way to define an implicit many-to-many relationship. @@ -264,7 +264,7 @@ model Category { ### Problem -Some cloud providers enforce the existence of primary keys in all tables. However, any relation tables (JOIN tables) created by Prisma (expressed via `@relation`) for many-to-many relations using implicit syntax do not have primary keys. +Some cloud providers enforce the existence of primary keys in all tables. However, any relation tables (JOIN tables) created by Prisma ORM (expressed via `@relation`) for many-to-many relations using implicit syntax do not have primary keys. ### Solution 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 ad763bce79..550743b1b8 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 @@ -46,12 +46,12 @@ model Post { -At a Prisma level, the `User` / `Post` relation is made up of: +At a Prisma ORM level, the `User` / `Post` relation is made up of: -- Two [relation fields](#relation-fields): `author` and `posts`. Relation fields define connections between models at the Prisma level and **do not exist in the database**. These fields are used to generate Prisma Client. +- Two [relation fields](#relation-fields): `author` and `posts`. Relation fields define connections between models at the Prisma ORM level and **do not exist in the database**. These fields are used to generate Prisma Client. - The scalar `authorId` field, which is referenced by the `@relation` attribute. This field **does exist in the database** - it is the foreign key that connects `Post` and `User`. -At a Prisma level, a connection between two models is **always** represented by a [relation field](#relation-fields) on **each side** of the relation. +At a Prisma ORM level, a connection between two models is **always** represented by a [relation field](#relation-fields) on **each side** of the relation.
@@ -91,7 +91,7 @@ author User @relation(fields: [authorId], references: [id]) ### MongoDB -For MongoDB, Prisma currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. +For MongoDB, Prisma ORM currently uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. The following document represents a `User` (in the `User` collection): @@ -209,7 +209,7 @@ In this query, the current value of `authorID` does not matter. The query change ## Types of relations -There are three different types (or [cardinalities]()) of relations in Prisma: +There are three different types (or [cardinalities]()) of relations in Prisma ORM: - [One-to-one](one-to-one-relations) (also called 1-1 relations) - [One-to-many](one-to-many-relations) (also called 1-n relations) @@ -302,14 +302,14 @@ For relational databases, the following entity relationship diagram represents t ![The sample schema as an entity relationship diagram](sample-schema.png) -For MongoDB, Prisma uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. See [the MongoDB section](#mongodb) for more details. +For MongoDB, Prisma ORM uses a [normalized data model design](https://docs.mongodb.com/manual/core/data-model-design/), which means that documents reference each other by ID in a similar way to relational databases. See [the MongoDB section](#mongodb) for more details. ### Implicit and explicit many-to-many relations Many-to-many relations in relational databases can be modelled in two ways: - [explicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#explicit-many-to-many-relations), where the relation table is represented as an explicit model in your Prisma schema -- [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations), where Prisma manages the relation table and it does not appear in the Prisma schema. +- [implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations), where Prisma ORM manages the relation table and it does not appear in the Prisma schema. Implicit many-to-many relations require both models to have a single `@id`. Be aware of the following: @@ -318,11 +318,11 @@ Implicit many-to-many relations require both models to have a single `@id`. Be a To use either of these features, you must set up an explicit many-to-many instead. -The implicit many-to-many relation still manifests in a relation table in the underlying database. However, Prisma manages this relation table. +The implicit many-to-many relation still manifests in a relation table in the underlying database. However, Prisma ORM manages this relation table. If you use an implicit many-to-many relation instead of an explicit one, it makes the [Prisma Client API](/orm/prisma-client) simpler (because, for example, you have one fewer level of nesting inside of [nested writes](/orm/prisma-client/queries/relation-queries#nested-writes)). -If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit many-to-many relations by following Prisma's [conventions for relation tables](many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations). +If you're not using Prisma Migrate but obtain your data model from [introspection](/orm/prisma-schema/introspection), you can still make use of implicit many-to-many relations by following Prisma ORM's [conventions for relation tables](many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations). ## Relation fields @@ -381,7 +381,7 @@ These models have the following fields: | `User` | `id` | `Int` | No | | | `email` | `String` | No | | | `role` | `Role` | No | -| | `posts` | `Post[]` | **Yes** (Prisma-level) | +| | `posts` | `Post[]` | **Yes** (Prisma ORM-level) | | `Post` | `id` | `Int` | No | | | `title` | `String` | No | | | `authorId` | `Int` | No (_relation scalar field_) | @@ -395,7 +395,7 @@ These models have the following fields: | `User` | `id` | `String` | No | Underlying database type is `ObjectId` | | | `email` | `String` | No | | | `role` | `Role` | No | -| | `posts` | `Post[]` | **Yes** (Prisma-level) | +| | `posts` | `Post[]` | **Yes** (Prisma ORM-level) | | `Post` | `id` | `String` | No | | | `title` | `String` | No | | | `authorId` | `String` | No (_relation scalar field_) | Underlying database type is `ObjectId` | @@ -408,7 +408,7 @@ Both `posts` and `author` are relation fields because their types are not scalar Also note that the annotated relation field `author` needs to link the relation scalar field `authorId` on the `Post` model inside the `@relation` attribute. The relation scalar represents the foreign key in the underlying database. -The other relation field called `posts` is defined purely on a Prisma-level, it doesn't manifest in the database. +The other relation field called `posts` is defined purely on a Prisma ORM-level, it doesn't manifest in the database. ### Annotated relation fields 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 9d2deaa9b2..77eaeaa5cd 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 @@ -7,7 +7,7 @@ tocDepth: 3 -Prisma allows configuration of database indexes, unique constraints and primary key constraints. This is in General Availability in versions `4.0.0` and later. You can enable this with the `extendedIndexes` Preview feature in versions `3.5.0` and later. +Prisma ORM allows configuration of database indexes, unique constraints and primary key constraints. This is in General Availability in versions `4.0.0` and later. You can enable this with the `extendedIndexes` Preview feature in versions `3.5.0` and later. 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. @@ -58,7 +58,7 @@ model Id { } ``` -This is not valid in MySQL because it exceeds MySQL's index storage limit and therefore Prisma rejects the data model. The generated SQL would be rejected by the database. +This is not valid in MySQL because it exceeds MySQL's index storage limit and therefore Prisma ORM rejects the data model. The generated SQL would be rejected by the database. ```sql CREATE TABLE `Id` ( @@ -74,9 +74,9 @@ model Id { } ``` -Prisma Migrate is able to create constraints and indexes with the `length` argument if specified in your data model. This means that you can create indexes and constraints on values of Prisma type `Byte` and `String`. If you don't specify the argument the index is treated as covering the full value as before. +Prisma Migrate is able to create constraints and indexes with the `length` argument if specified in your data model. This means that you can create indexes and constraints on values of Prisma schema type `Byte` and `String`. If you don't specify the argument the index is treated as covering the full value as before. -Introspection will fetch these limits where they are present in your existing database. This allows Prisma to support indexes and constraints that were previously suppressed and results in better support of existing MySQL databases that are making use of this feature. +Introspection will fetch these limits where they are present in your existing database. This allows Prisma ORM to support indexes and constraints that were previously suppressed and results in better support of MySQL databases utilizing this feature. The `length` argument can also be used on compound primary keys, using the `@@id` attribute, as in the example below: @@ -93,7 +93,7 @@ A similar syntax can be used for the `@@unique` and `@@index` attributes. ### Configuring the index sort order with sort -The `sort` argument is available for all databases supported by Prisma. It allows you to specify the order that the entries of the index or constraint are stored in the database. This can have an effect on whether the database is able to use an index for specific queries. +The `sort` argument is available for all databases supported by Prisma ORM. It allows you to specify the order that the entries of the index or constraint are stored in the database. This can have an effect on whether the database is able to use an index for specific queries. The `sort` argument is available for all databases on `@unique`, `@@unique` and `@@index`. Additionally, SQL Server also allows it on `@id` and `@@id`. It is generally available in versions 4.0.0 and later, and available as part of the `extendedIndexes` preview feature in versions 3.5.0 and later. @@ -180,7 +180,7 @@ An indexed field can define the operator class, which defines the operators hand -Indexes using a function (such as `to_tsvector`) to determine the indexed value are not yet supported by Prisma. Indexes defined in this way will not be visible with `prisma db pull`. +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`. @@ -212,7 +212,7 @@ As part of the `JsonbPathOps` the `@>` operator is handled by the index, speedin ##### Supported Operator Classes for GIN -Prisma generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. +Prisma ORM generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma ORM does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. The default operator class (marked with ✅) can be omitted from the index definition. @@ -227,7 +227,7 @@ Read more about built-in operator classes in the [official PostgreSQL documentat ##### CockroachDB -GIN and BTree are the only index types supported by CockroachDB. The operator classes marked to work with CockroachDB are the only ones allowed on that database and supported by Prisma. The operator class cannot be defined in the Prisma Schema Language: the `ops` argument is not necessary or allowed on CockroachDB. +GIN and BTree are the only index types supported by CockroachDB. The operator classes marked to work with CockroachDB are the only ones allowed on that database and supported by Prisma ORM. The operator class cannot be defined in the Prisma Schema Language: the `ops` argument is not necessary or allowed on CockroachDB. #### Generalized Search Tree (GiST) @@ -262,7 +262,7 @@ Queries comparing IP addresses, such as `value > '10.0.0.2'`, will use the index ##### Supported Operator Classes for GiST -Prisma generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. +Prisma ORM generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma ORM does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. | Operator class | Allowed field type (allowed native types) | | -------------- | ----------------------------------------- | @@ -308,7 +308,7 @@ Queries such as `value LIKE 'something%'` will be sped up by the index. ##### Supported Operator Classes for SP-GiST -Prisma generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. +Prisma ORM generally supports operator classes provided by PostgreSQL in versions 10 and later. If the operator class requires the field type to be of a type Prisma ORM does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. The default operator class (marked with ✅) can be omitted from the index definition. @@ -352,7 +352,7 @@ Queries like `value = 2` will now use the index, which uses a fraction of the sp ##### Supported Operator Classes for BRIN -Prisma generally supports operator classes provided by PostgreSQL in versions 10 and later, and some supported operators are only available from PostgreSQL versions 14 and later. If the operator class requires the field type to be of a type Prisma does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. +Prisma ORM generally supports operator classes provided by PostgreSQL in versions 10 and later, and some supported operators are only available from PostgreSQL versions 14 and later. If the operator class requires the field type to be of a type Prisma ORM does not yet support, using the `raw` function with a string input allows you to use these operator classes without validation. The default operator class (marked with ✅) can be omitted from the index definition. @@ -459,10 +459,10 @@ These index configuration changes can be **breaking changes** when activating th A breaking change can occur in the following situations: -- **Existing sort constraints and indexes:** earlier versions of Prisma will assume that the desired sort order is _ascending_ if no order is specified explicitly. This means that this is a breaking change if you have existing constraints or indexes that are using descending sort order and migrate your database without first specifying this in your data model. -- **Existing length constraints and indexes:** in earlier versions of Prisma, indexes and constraints that were length constrained in MySQL could not be represented in the Prisma schema. Therefore `prisma db pull` was not fetching these and you could not manually specify them. When you ran `prisma db push` or `prisma migrate dev` they were ignored if already present in your database. Since you are now able to specify these, migrate commands will now drop them if they are missing from your data model but present in the database. -- **Existing indexes other than `BTree` (PostgreSQL):** earlier versions of Prisma only supported the default `BTree` index type. Other supported indexes (`Hash`, `Gist`, `Gin`, `SpGist` and `Brin`) need to be added before migrating your database. -- **Existing (non-)clustered indexes (SQL Server):** earlier versions of Prisma did not support configuring an index as clustered or non-clustered. For indexes that do not use the default, these need to be added before migrating your database. +- **Existing sort constraints and indexes:** earlier versions of Prisma ORM will assume that the desired sort order is _ascending_ if no order is specified explicitly. This means that this is a breaking change if you have existing constraints or indexes that are using descending sort order and migrate your database without first specifying this in your data model. +- **Existing length constraints and indexes:** in earlier versions of Prisma ORM, indexes and constraints that were length constrained in MySQL could not be represented in the Prisma schema. Therefore `prisma db pull` was not fetching these and you could not manually specify them. When you ran `prisma db push` or `prisma migrate dev` they were ignored if already present in your database. Since you are now able to specify these, migrate commands will now drop them if they are missing from your data model but present in the database. +- **Existing indexes other than `BTree` (PostgreSQL):** earlier versions of Prisma ORM only supported the default `BTree` index type. Other supported indexes (`Hash`, `Gist`, `Gin`, `SpGist` and `Brin`) need to be added before migrating your database. +- **Existing (non-)clustered indexes (SQL Server):** earlier versions of Prisma ORM did not support configuring an index as clustered or non-clustered. For indexes that do not use the default, these need to be added before migrating your database. In each of the cases above unwanted changes to your database can be prevented by properly specifying these properties in your data model where necessary. **The easiest way to do this is to use `prisma db pull` to retrieve any existing constraints or configuration.** Alternatively, you could also add these arguments manually. This should be done before using `prisma db push` or `prisma migrate dev` the first time after the upgrade. @@ -531,4 +531,4 @@ This can be a **breaking change** when activating the functionality for certain, -Earlier versions of Prisma 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. +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 14073f18af..6bef15664a 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 @@ -17,7 +17,7 @@ Support for views is currently a very early [Preview](/orm/more/releases#preview Database views allow you to name and store queries. In relational databases, views are [stored SQL queries](https://www.postgresql.org/docs/current/sql-createview.html) that might include columns in multiple tables, or calculated values such as aggregates. In MongoDB, views are queryable objects where the contents are defined by an [aggregation pipeline](https://www.mongodb.com/docs/manual/core/aggregation-pipeline) on other collections. -The `views` preview feature allows you to represent views in your Prisma schema with the `view` keyword. To use views in Prisma, follow these steps: +The `views` preview feature allows you to represent views in your Prisma schema with the `view` keyword. To use views in Prisma ORM, follow these steps: - [Enable the `views` preview feature](#enable-the-views-preview-feature) - [Create a view in the underlying database](#create-a-view-in-the-underlying-database), either directly or as a [manual addition to a Prisma Migrate migration file](#use-views-with-prisma-migrate-and-db-push), or use an existing view @@ -123,7 +123,7 @@ db.createView('UserInfo', 'User', [ ## Use views with Prisma Migrate and db push -If you apply changes to your Prisma schema with Prisma Migrate or `db push`, Prisma does not create or run any SQL related to views. +If you apply changes to your Prisma schema with Prisma Migrate or `db push`, Prisma ORM does not create or run any SQL related to views. To include views in a migration, run `migrate dev --create-only` and then manually add the SQL for views to your migration file. Alternatively, you can create views manually in the database. @@ -274,7 +274,7 @@ In order to make this `view` block valid you will need to: - Remove the _optional_ flag `?` from the `id` field - Add the `@unique` attribute to the `id` field - Remove the `@@ignore` attribute -- Remove the comment Prisma generated warning about an invalid view +- Remove the generated comment warning about an invalid view ```prisma highlight=4;add|1,3,8,9;delete @@ -315,7 +315,7 @@ FROM #### Unique Identifier -Currently, Prisma treats views in the same way as models. This means that a view needs to have at least one _unique identifier_, which can be represented by any of the following: +Currently, Prisma ORM treats views in the same way as models. This means that a view needs to have at least one _unique identifier_, which can be represented by any of the following: - A unique constraint denoted with [`@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) - A composite unique constraint denoted with [`@@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) @@ -350,13 +350,13 @@ Currently, Prisma Client allows you to update a view if the underlying database ## Special types of views -This section describes how to use Prisma with updatable and materialized views in your database. +This section describes how to use Prisma ORM with updatable and materialized views in your database. ### Updatable views Some databases support updatable views (e.g. [PostgreSQL](https://www.postgresql.org/docs/current/sql-createview.html#SQL-CREATEVIEW-UPDATABLE-VIEWS), [MySQL](https://dev.mysql.com/doc/refman/8.0/en/view-updatability.html) and [SQL Server](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-ver16#updatable-views)). Updatable views allow you to create, update or delete entries. -Currently Prisma treats all `view`s as updatable views. If the underlying database supports this functionality for the view, the operation should succeed. If the view is not marked as updatable, the database will return an error, and Prisma Client will then throw this error. +Currently Prisma ORM treats all `view`s as updatable views. If the underlying database supports this functionality for the view, the operation should succeed. If the view is not marked as updatable, the database will return an error, and Prisma Client will then throw this error. In the future, Prisma Client might support marking individual views as updatable or not updatable. Please comment on our [`views` feedback issue](https://github.com/prisma/prisma/issues/17335) with your use case. @@ -366,6 +366,6 @@ Some databases support materialized views, e.g. [PostgreSQL](https://www.postgre Materialized views persist the result of the view query for faster access and only update it on demand. -Currently Prisma has no understanding of materialized views, but when you [manually create a view](#create-a-view-in-the-underlying-database) you can also create a materialized view by using the corresponding command in the underlying database. You can then use Prisma's [raw query functionality](/orm/prisma-client/queries/raw-database-access) to execute the command to refresh the view manually. +Currently Prisma ORM has no understanding of materialized views, but when you [manually create a view](#create-a-view-in-the-underlying-database) you can also create a materialized view by using the corresponding command in the underlying database. You can then use Prisma Client's [raw query functionality](/orm/prisma-client/queries/raw-database-access) to execute the command to refresh the view manually. In the future Prisma Client might support marking individual views as materialized and add a Prisma Client method to refresh the materialized view. Please comment on our [`views` feedback issue](https://github.com/prisma/prisma/issues/17335) with your use case. 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 7f7281dbf8..9c4f230645 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 @@ -20,7 +20,7 @@ The [Prisma schema](/orm/prisma-schema) includes mechanisms that allow you to de Sometimes the names used to describe entities in your database might not match the names you would prefer in your generated API. Mapping names in the Prisma schema allows you to influence the naming in your Client API without having to change the underlying database names. -A common approach for naming tables/collections in databases for example is to use plural form and [snake_case](https://en.wikipedia.org/wiki/Snake_case) notation. Prisma on the other hand has recommended model [naming conventions (singular form, PascalCase)](/orm/reference/prisma-schema-reference#naming-conventions) which differ from that. +A common approach for naming tables/collections in databases for example is to use plural form and [snake_case](https://en.wikipedia.org/wiki/Snake_case) notation. However, we recommended a different [naming convention (singular form, PascalCase)](/orm/reference/prisma-schema-reference#naming-conventions). `@map` and `@@map` allow you to [tune the shape of your Prisma Client API](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) by decoupling model and field names from table and column names in the underlying database. @@ -44,7 +44,7 @@ model Comment { } ``` -With this modified model definition, Prisma automatically maps the `Comment` model to the `comments` table in the underlying database. +With this modified model definition, Prisma Client automatically maps the `Comment` model to the `comments` table in the underlying database. ### Map field / column names @@ -77,13 +77,13 @@ enum Type { ## Constraint and index names -In [2.29.0](https://github.com/prisma/prisma/releases/tag/2.29.0) and later, you can optionally use the `map` argument to define the **underlying constraint and index names** in the Prisma schema for the attributes [`@id`](/orm/reference/prisma-schema-reference#id), [`@@id`](/orm/reference/prisma-schema-reference#id-1), [`@unique`](/orm/reference/prisma-schema-reference#unique), [`@@unique`](/orm/reference/prisma-schema-reference#unique-1), [`@@index`](/orm/reference/prisma-schema-reference#index) and [`@relation`](/orm/reference/prisma-schema-reference#relation). +You can optionally use the `map` argument to explicitly define the **underlying constraint and index names** in the Prisma schema for the attributes [`@id`](/orm/reference/prisma-schema-reference#id), [`@@id`](/orm/reference/prisma-schema-reference#id-1), [`@unique`](/orm/reference/prisma-schema-reference#unique), [`@@unique`](/orm/reference/prisma-schema-reference#unique-1), [`@@index`](/orm/reference/prisma-schema-reference#index) and [`@relation`](/orm/reference/prisma-schema-reference#relation). (This is available in Prisma ORM version [2.29.0](https://github.com/prisma/prisma/releases/tag/2.29.0) and later.) -When introspecting a database, the `map` argument will _only_ be rendered in the schema if the name differs from Prisma's [default constraint naming convention for indexes and constraints](#prismas-default-naming-conventions-for-indexes-and-constraints). +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). -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'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). +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). @@ -94,11 +94,11 @@ Some use cases for explicitly named constraints include: - Company policy - Conventions of other tools -#### Prisma's default naming conventions for indexes and constraints +### Prisma ORM's default naming conventions for indexes and constraints -Prisma naming convention was chosen to align with PostgreSQL since it is deterministic. It also helps to maximize the amount of times where names do not need to be rendered because many databases out there they already align with the convention. +Prisma ORM naming convention was chosen to align with PostgreSQL since it is deterministic. It also helps to maximize the amount of times where names do not need to be rendered because many databases out there they already align with the convention. -We always use the database names of entities when generating the default names. So if a model is remapped to a different name in the data model, the default name generation will still take the name of the table in the database as input. The same is true for fields and columns. +Prisma ORM always uses the database names of entities when generating the default index and constraint names. If a model is remapped to a different name in the data model via `@@map` or `@map`, the default name generation will still take the name of the _table_ in the database as input. The same is true for fields and _columns_. | Entity | Convention | Example | | ----------------- | --------------------------------- | ------------------------------ | @@ -111,13 +111,13 @@ Since most databases have a length limit for entity names, the names will be tri ### Using default constraint names -When no explicit names are provided via `map` arguments Prisma will assume they follow the default naming convention. +When no explicit names are provided via `map` arguments Prisma ORM will generate index and constraint names following the [default naming convention](#prisma-orms-default-naming-conventions-for-indexes-and-constraints). -If you introspect a database the names for indexes and constraints will be added to your schema unless they follow Prisma's naming convention. If they do, the names are not rendered to keep the schema more readable. When you migrate such a schema Prisma will infer the default names and persist them in the database. +If you introspect a database the names for indexes and constraints will be added to your schema unless they follow Prisma ORM's naming convention. If they do, the names are not rendered to keep the schema more readable. When you migrate such a schema Prisma will infer the default names and persist them in the database. #### Example -The following schema defines three constraints (`@id`, `@unique`, and `@relation`) and one index (`@@index`) that will +The following schema defines three constraints (`@id`, `@unique`, and `@relation`) and one index (`@@index`): ```prisma highlight=2,8,11,13;normal model User { @@ -138,19 +138,13 @@ model Post { Since no explicit names are provided via `map` arguments Prisma will assume they follow our default naming convention. -### Prisma's default naming conventions for indexes and constraints - -If you introspect a database the names for indexes and constraints will be added to your schema unless they follow Prisma's naming convention. If they do, the names are not rendered to keep the schema more readable. When you migrate such a schema Prisma will infer the default names and persist them in the database. - -We chose our naming convention to align with PostgreSQL since it is deterministic and helps us maximize the amount of times where we do not need -to render names because they already align with the convention. - -| Constraint or index | Follows convention | Underlying constraint or index names | +The following table lists the name of each constraint and index in the underlying database: +| Constraint or index | Follows convention | Underlying constraint or index names | | ---------------------------------- | ------------------ | ------------------------------------ | -| `@id` (on `User` > `id` field) | Yes | `User_pk` | -| `@@index` (on `Post`) | Yes | `Post_title_authorName_idx` | -| `@id` (on `Post` > `id` field) | Yes | `Post_pk` | -| `@relation` (on `Post` > `author`) | Yes | `Post_authorName_fkey` | +| `@id` (on `User` > `id` field) | Yes | `User_pk` | +| `@@index` (on `Post`) | Yes | `Post_title_authorName_idx` | +| `@id` (on `Post` > `id` field) | Yes | `Post_pk` | +| `@relation` (on `Post` > `author`) | Yes | `Post_authorName_fkey` | ### Using custom constraint / index names 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 3ab4d0a631..4d2bb4fb94 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 @@ -1,7 +1,7 @@ --- -title: How to use Prisma with multiple database schemas -metaTitle: How to use Prisma with multiple database schemas -metaDescription: How to use Prisma with multiple database schemas +title: How to use Prisma ORM with multiple database schemas +metaTitle: How to use Prisma ORM with multiple database schemas +metaDescription: How to use Prisma ORM with multiple database schemas tocDepth: 3 --- @@ -15,7 +15,7 @@ Multiple database schema support is currently available with the PostgreSQL, Coc Many database providers allow you to organize database tables into named groups. You can use this to make the logical structure of the data model easier to understand, or to avoid naming collisions between tables. -In PostgreSQL, CockroachDB, and SQL Server, these groups are known as schemas. We will refer to them as _database schemas_ to distinguish them from Prisma's own schema file. +In PostgreSQL, CockroachDB, and SQL Server, these groups are known as schemas. We will refer to them as _database schemas_ to distinguish them from Prisma ORM's own schema file. This guide explains how to: @@ -157,7 +157,7 @@ You can then apply this schema change to your database. For example, you can use npx prisma migrate dev --name add_profile ``` -Note that if you move a model or enum from one schema to another, Prisma deletes the model or enum from the source schema and creates a new one in the target schema. +Note that if you move a model or enum from one schema to another, Prisma ORM deletes the model or enum from the source schema and creates a new one in the target schema. ## How to introspect an existing database with multiple database schemas @@ -169,7 +169,7 @@ npx prisma db pull This updates your Prisma schema to match the current state of the database. -If you have tables with the same name in different database schemas, Prisma shows a validation error pointing out the conflict. To fix this, [rename the introspected models with the `@map` attribute](#tables-with-the-same-name-in-different-database-schemas). +If you have tables with the same name in different database schemas, Prisma ORM shows a validation error pointing out the conflict. To fix this, [rename the introspected models with the `@map` attribute](#tables-with-the-same-name-in-different-database-schemas). ## How to query across multiple database schemas with Prisma Client 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 8daa975dc6..9f4a709645 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 @@ -6,13 +6,13 @@ tocDepth: 2 -Not all database functions and features of all of Prisma's supported databases have a Prisma Schema Language equivalent. Refer to the [database features matrix](/orm/reference/database-features) for a complete list of supported features. +Not all database functions and features of Prisma ORM's supported databases have a Prisma Schema Language equivalent. Refer to the [database features matrix](/orm/reference/database-features) for a complete list of supported features. ## Native database functions -Prisma Schema Language supports several [functions](/orm/reference/prisma-schema-reference#attribute-functions) that you can use to set the default value of a field. The following example uses the Prisma-level `uuid()` function to set the value of the `id` field: +Prisma Schema Language supports several [functions](/orm/reference/prisma-schema-reference#attribute-functions) that you can use to set the default value of a field. The following example uses the Prisma ORM-level `uuid()` function to set the value of the `id` field: ```prisma model Post { @@ -32,8 +32,8 @@ model User { There are two reasons to use a database-level function: -- There is no equivalent Prisma function (for example, `gen_random_bytes` in PostgreSQL). -- You cannot or do not want to rely on functions such `uuid()` and `cuid()`, which are only implemented at Prisma level and do not manifest in the database. +- There is no equivalent Prisma ORM function (for example, `gen_random_bytes` in PostgreSQL). +- You cannot or do not want to rely on functions such `uuid()` and `cuid()`, which are only implemented at a Prisma ORM level and do not manifest in the database. Consider the following example, which sets the `id` field to a randomly generated `UUID`: @@ -51,7 +51,7 @@ In PostgreSQL, some native database functions are part of an extension. For exam To use a PostgreSQL extension, you must first install it on the file system of your database server. -In Prisma versions 4.5.0 and later, you can then activate the extension by declaring it in your Prisma schema with the [`postgresqlExtensions` preview feature](/orm/prisma-schema/postgresql-extensions): +In Prisma ORM versions 4.5.0 and later, you can then 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 generator client { @@ -66,7 +66,7 @@ datasource db { } ``` -In earlier versions of Prisma, you must instead run a SQL command to activate the extension: +In earlier versions of Prisma ORM, you must instead run a SQL command to activate the extension: ```sql CREATE EXTENSION IF NOT EXISTS pgcrypto; 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 new file mode 100644 index 0000000000..eb8c6cd1e3 --- /dev/null +++ b/content/200-orm/100-prisma-schema/20-data-model/80-table-inheritance.mdx @@ -0,0 +1,328 @@ +--- +title: Table inheritance +metaTitle: Table inheritance +metaDescription: Learn about the use cases and patterns for table inheritance in Prisma ORM that enable usage of union types or polymorphic structures in your application. +tocDepth: 3 +--- + +## Overview + +Table inheritance is a software design pattern that allows the modeling of hierarchical relationships between entities. Using table inheritance on the database level can also enable the use of union types in your JavaScript/TypeScript application or share a set of common properties across multiple models. + +This page introduces two approaches to table inheritance and explains how to use them with Prisma ORM. + +A common use case for table inheritance may be when an application needs to display a _feed_ of some kind of _content activities_. A content activity in this case, could be a _video_ or an _article_. As an example, let's assume that: + +- a content activity always has an `id` and a `url` +- in addition to `id` and a `url`, a video also has a `duration` (modeled as an `Int`) +- in addition to `id` and a `url`, an article also a `body` (modeled as a `String`) + +### Use cases + +#### Union types + +Union types are a convenient feature in TypeScript that allows developers to work more flexibly with the types in their data model. + +In TypeScript, union types look as follows: + +```ts no-copy +type Activity = Video | Article +``` + +While [it's currently not possible to model union types in the Prisma schema](https://github.com/prisma/prisma/issues/2505), you can use them with Prisma ORM by using table inheritance and some additional type definitions. + +#### Sharing properties across multiple models + +If you have a use case where multiple models should share a particular set of properties, you can model this using table inheritance as well. + +For example, if both the `Video` and `Article` models from above should have a shared `title` property, you can achieve this with table inheritance as well. + +### Example + +In a simple Prisma schema, this would look as follows. Note that we're adding a `User` model as well to illustrate how this can work with relations: + +```prisma file=schema.prisma +model Video { + id Int @id + url String @unique + duration Int + + user User @relation(fields: [userId], references: [id]) + userId Int +} + +model Article { + id Int @id + url String @unique + body String + + user User @relation(fields: [userId], references: [id]) + userId Int +} + +model User { + id Int @id + name String + videos Video[] + articles Article[] +} +``` + +Let's investigate how we can model this using table inheritance. + +### Single-table vs multi-table inheritance + +Here is a quick comparison of the two main approaches for table inheritance: + +- **Single-table inheritance (STI)**: Uses a _single_ table to store data of _all_ the different entities in one location. In our example, there'd be a single `Activity` table with the `id`, `url` as well as te `duration` and `body` column. It also uses a `type` column that indicates whether an _activity_ is a _video_ or an _article_. +- **Multi-table inheritance (MTI)**: Uses _multiple_ tables to store the data of the different entities separately and links them via foreign keys. In our example, there'd be an `Activity` table with the `id`, `url` column, a `Video` table with the `duration` and a foreign key to `Activity` as well as an `Article` table with the `body` and a foreign key. There is also a `type` column that acts as a discriminator and indicates whether an _activity_ is a _video_ or an _article_. Note that multi-table inheritance is also sometimes called _delegated types_. + +You can learn about the tradeoffs of both approaches [below](#tradeoffs-between-sti-and-mti). + +## Single-table inheritance (STI) + +### Data model + +Using STI, the above scenario can be modeled as follows: + +```prisma +model Activity { + id Int @id // shared + url String @unique // shared + duration Int? // video-only + body String? // article-only + type ActivityType // discriminator + + owner User @relation(fields: [ownerId], references: [id]) + ownerId Int +} + +enum ActivityType { + Video + Article +} + +model User { + id Int @id @default(autoincrement()) + name String? + activities Activity[] +} +``` + +A few things to note: + +- The model-specific properties `duration` and `body` must be marked as optional (i.e., with `?`). That's because a record in the `Activity` table that represents a _video_ must not have a value for `body`. Conversely, an `Activity` record representing an _article_ can never have a `duration` set. +- The `type` discriminator column indicates whether each record represents a _video_ or an _article_ item. + +### Prisma Client API + +Due to how Prisma ORM generates types and an API for the data model, there will only to be an `Activity` type and the CRUD queries that belong to it (`create`, `update`, `delete`, ...) available to you. + +#### Querying for videos and articles + +You can now query for only _videos_ or _articles_ by filtering on the `type` column. For example: + +```ts +// Query all videos +const videos = await prisma.activity.findMany({ + where: { type: 'Video' }, +}) + +// Query all articles +const articles = await prisma.activity.findMany({ + where: { type: 'Article' }, +}) +``` + +#### Defining dedicated types + +When querying for videos and articles like that, TypeScript will still only recognize an `Activity` type. That can be annoying because even the objects in `videos` will have (optional) `body` and the objects in `articles` will have (optional) `duration` fields. + +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' + +type Video = Omit +type Article = Omit +``` + +In addition, it will be helpful to convert mapping functions that convert an object of type `Activity` to the `Video` and `Article` types: + +```ts +function activityToVideo(activity: Activity): Video { + return { + url: activity.url, + duration: activity.duration ? activity.duration : -1, + ownerId: activity.ownerId, + } as Video +} + +function activityToArticle(activity: Activity): Article { + return { + url: activity.url, + body: activity.body ? activity.body : '', + ownerId: activity.ownerId, + } as Article +} +``` + +Now you can turn an `Activity` into a more specific type (i.e., `Article` or `Video`) after querying: + +```ts +const videoActivities = await prisma.activity.findMany({ + where: { type: 'Video' }, +}) +const videos: Video[] = videoActivities.map(activityToVideo) +``` + +#### Using Prisma Client extension for a more convenient API + +You can use [Prisma Client extensions](/orm/prisma-client/client-extensions) to create a more convenient API for the table structures in your database. + +## Multi-table inheritance (MTI) + +### Data model + +Using MTI, the above scenario can be modeled as follows: + +```prisma +model Activity { + id Int @id @default(autoincrement()) + url String // shared + type ActivityType // discriminator + + video Video? // model-specific 1-1 relation + article Article? // model-specific 1-1 relation + + owner User @relation(fields: [ownerId], references: [id]) + ownerId Int +} + +model Video { + id Int @id @default(autoincrement()) + duration Int // video-only + activityId Int @unique + activity Activity @relation(fields: [activityId], references: [id]) +} + +model Article { + id Int @id @default(autoincrement()) + body String // article-only + activityId Int @unique + activity Activity @relation(fields: [activityId], references: [id]) +} + +enum ActivityType { + Video + Article +} + +model User { + id Int @id @default(autoincrement()) + name String? + activities Activity[] +} +``` + +A few things to note: + +- A 1-1 relation is needed between `Activity` and `Video` as well as `Activity` and `Article`. This relationship is used to fetch the specific information about a record when needed. +- The model-specific properties `duration` and `body` can be made _required_ with this approach. +- The `type` discriminator column indicates whether each record represents a _video_ or an _article_ item. + +### Prisma Client API + +This time, you can query for videos and articles directly via the `video` and `article` properties on your `PrismaClient`` instance. + +#### Querying for videos and articles + +If you want to access the shared properties, you need to use `include` to fetch the relation to `Activity`. + +```ts +// Query all videos +const videos = await prisma.video.findMany({ + include: { activity: true }, +}) + +// Query all articles +const articles = await prisma.article.findMany({ + include: { activity: true }, +}) +``` + +Depending on your needs, you may also query the other way around by filtering on the `type` discriminator column: + +```ts +// Query all videos +const videoActivities = await prisma.activity.findMany({ + where: { type: 'Video' } + include: { video: true } +}) +``` + +#### Defining dedicated types + +While a bit more convenient in terms of types compare STI, the generated typings likely still won't fit all your needs. + +Here's how you can define `Video` and `Article` types by combining Prisma ORM's generated `Video` and `Article` types with the `Activity` type. These combinations create a new type with the desired properties. Note that we're also omitting the `type` discriminator column because that's not needed anymore on the specific types: + +```ts +import { + Video as VideoDB, + Article as ArticleDB, + Activity, +} from '@prisma/client' + +type Video = Omit +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' + +type Video = Omit + +// Create `VideoWithActivity` typings for the objects returned above +const videoWithActivity = Prisma.validator()({ + include: { activity: true }, +}) +type VideoWithActivity = Prisma.VideoGetPayload + +// Map to `Video` type +function toVideo(a: VideoWithActivity): Video { + return { + id: a.id, + url: a.activity.url, + ownerId: a.activity.ownerId, + duration: a.duration, + activityId: a.activity.id, + } +} +``` + +Now you can take the objects returned by the queries above and transform them using `toVideo`: + +```ts +const videoWithActivities = await prisma.video.findMany({ + include: { activity: true }, +}) +const videos: Video[] = videoWithActivities.map(toVideo) +``` + +#### Using Prisma Client extension for a more convenient API + +You can use [Prisma Client extensions](/orm/prisma-client/client-extensions) to create a more convenient API for the table structures in your database. + +## Tradeoffs between STI and MTI + +- **Data model**: The data model may feel more clean with MTI. With STI, you may end up with very wide rows and lots of columns that have `NULL` values in them. +- **Performance**: MTI may come with a performance cost because you need to join the parent and child tables to access _all_ properties relevant for a model. +- **Typings**: With Prisma ORM, MTI gives you proper typings for the specific models (i.e., `Article` and `Video` in the examples above) already, while you need to create these from scratch with STI. +- **IDs / Primary keys**: With MTI, records have two IDs (one on the parent and another on the child table) that may not match. You need to consider this in the business logic of your application. + +## Third-party solutions + +While Prisma ORM doesn't natively support union types or polymorphism at the moment, you can check out [Zenstack](https://github.com/zenstackhq/zenstack) which is adding an extra layer of features to the Prisma schema. Read their [blog post about polymorphism in Prisma ORM](https://zenstack.dev/blog/polymorphism) to learn more. diff --git a/content/200-orm/100-prisma-schema/20-data-model/index.mdx b/content/200-orm/100-prisma-schema/20-data-model/index.mdx index 38f3f46a38..c1e95ce4c4 100644 --- a/content/200-orm/100-prisma-schema/20-data-model/index.mdx +++ b/content/200-orm/100-prisma-schema/20-data-model/index.mdx @@ -1,7 +1,7 @@ --- title: 'Data model' metaTitle: 'Data model' -metaDescription: 'Learn everything you need about the Prisma data model.' +metaDescription: 'Learn everything you need about the Prisma schema data model.' toc: false --- diff --git a/content/200-orm/100-prisma-schema/50-introspection.mdx b/content/200-orm/100-prisma-schema/50-introspection.mdx index a64066e986..ee4d3618e5 100644 --- a/content/200-orm/100-prisma-schema/50-introspection.mdx +++ b/content/200-orm/100-prisma-schema/50-introspection.mdx @@ -8,7 +8,7 @@ metaDescription: 'Learn how you can introspect your database to generate a data You can introspect your database using the Prisma CLI in order to generate the [data model](/orm/prisma-schema/data-model) in your [Prisma schema](/orm/prisma-schema). The data model is needed to [generate Prisma Client](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names). -Introspection is often used to generate an _initial_ version of the data model when [adding Prisma to an existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql). +Introspection is often used to generate an _initial_ version of the data model when [adding Prisma ORM to an existing project](/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql). However, it can also be [used _repeatedly_ in an application](#introspection-with-an-existing-schema). This is most commonly the case when you're _not_ using [Prisma Migrate](/orm/prisma-migrate) but perform schema migrations using plain SQL or another migration tool. In that case, you also need to re-introspect your database and subsequently re-generate Prisma Client to reflect the schema changes in your [Prisma Client API](/orm/prisma-client). @@ -33,7 +33,7 @@ On MongoDB, the main functions are the following: - Map _documents_ in the collections to the [fields](/orm/prisma-schema/data-model/models#defining-fields) of Prisma models by _sampling them_ - Map _indexes_ in the database to [indexes](/orm/prisma-schema/data-model/models#defining-an-index) in the Prisma schema, if the collection contains at least one document contains a field included in the index -You can learn more about how Prisma maps types from the database to the types available in the Prisma schema on the respective docs page for the data source connector: +You can learn more about how Prisma ORM maps types from the database to the types available in the Prisma schema on the respective docs page for the data source connector: - [PostgreSQL](/orm/overview/databases/postgresql#type-mapping-between-postgresql-and-prisma-schema) - [MySQL](/orm/overview/databases/mysql#type-mapping-between-mysql-to-prisma-schema) @@ -49,7 +49,7 @@ Here's a high-level overview of the steps that `prisma db pull` performs interna 1. Read the [connection URL](/orm/reference/connection-urls) from the `datasource` configuration in the Prisma schema 1. Open a connection to the database 1. Introspect database schema (i.e. read tables, columns and other structures ...) -1. Transform database schema into Prisma data model +1. Transform database schema into Prisma schema data model 1. Write data model into Prisma schema or [update existing schema](#introspection-with-an-existing-schema) ## Introspection workflow @@ -67,7 +67,7 @@ Note that as you evolve the application, [this process can be repeated for an in ## Rules and conventions -Prisma employs a number of conventions for translating a database schema into a Prisma data model: +Prisma ORM employs a number of conventions for translating a database schema into a data model in the Prisma schema: ### Model, field and enum names @@ -102,7 +102,7 @@ CREATE TABLE "42User" ( ); ``` -Because the leading `42` in the table name as well as the leading underscores and the `$` on the columns are forbidden in Prisma, introspection adds the `@map` and `@@map` attributes so that these names adhere to Prisma's naming conventions: +Because the leading `42` in the table name as well as the leading underscores and the `$` on the columns are forbidden in Prisma ORM, introspection adds the `@map` and `@@map` attributes so that these names adhere to Prisma ORM's naming conventions: ```prisma model User { @@ -192,11 +192,11 @@ Introspection adds attributes in the following order (this order is mirrored by ### Relations -Prisma translates foreign keys that are defined on your database tables into [relations](/orm/prisma-schema/data-model/relations). +Prisma ORM translates foreign keys that are defined on your database tables into [relations](/orm/prisma-schema/data-model/relations). #### One-to-one relations -Prisma adds a [one-to-one](/orm/prisma-schema/data-model/relations/one-to-one-relations) relation to your data model when the foreign key on a table has a `UNIQUE` constraint, e.g.: +Prisma ORM adds a [one-to-one](/orm/prisma-schema/data-model/relations/one-to-one-relations) relation to your data model when the foreign key on a table has a `UNIQUE` constraint, e.g.: ```sql CREATE TABLE "User" ( @@ -209,7 +209,7 @@ CREATE TABLE "Profile" ( ); ``` -Prisma translates this into the following data model: +Prisma ORM translates this into the following data model: ```prisma model User { @@ -226,7 +226,7 @@ model Profile { #### One-to-many relations -By default, Prisma adds a [one-to-many](/orm/prisma-schema/data-model/relations/one-to-many-relations) relation to your data model for a foreign key it finds in your database schema: +By default, Prisma ORM adds a [one-to-many](/orm/prisma-schema/data-model/relations/one-to-many-relations) relation to your data model for a foreign key it finds in your database schema: ```sql CREATE TABLE "User" ( @@ -258,18 +258,18 @@ model Post { [Many-to-many](/orm/prisma-schema/data-model/relations/many-to-many-relations) relations are commonly represented as [relation tables](/orm/prisma-schema/data-model/relations/many-to-many-relations#relation-tables) in relational databases. -Prisma supports two ways for defining many-to-many relations in the Prisma schema: +Prisma ORM supports two ways for defining many-to-many relations in the Prisma schema: -- [Implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations) (Prisma manages the relation table under the hood) +- [Implicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#implicit-many-to-many-relations) (Prisma ORM manages the relation table under the hood) - [Explicit many-to-many relations](/orm/prisma-schema/data-model/relations/many-to-many-relations#explicit-many-to-many-relations) (the relation table is present as a [model](/orm/prisma-schema/data-model/models#defining-models)) -_Implicit_ many-to-many relations are recognized if they adhere to Prisma's [conventions for relation tables](/orm/prisma-schema/data-model/relations/many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations). Otherwise the relation table is rendered in the Prisma schema as a model (therefore making it an _explicit_ many-to-many relation). +_Implicit_ many-to-many relations are recognized if they adhere to Prisma ORM's [conventions for relation tables](/orm/prisma-schema/data-model/relations/many-to-many-relations#conventions-for-relation-tables-in-implicit-m-n-relations). Otherwise the relation table is rendered in the Prisma schema as a model (therefore making it an _explicit_ many-to-many relation). This topic is covered extensively on the docs page about [Relations](/orm/prisma-schema/data-model/relations). #### Disambiguating relations -Prisma generally omits the `name` argument on the [`@relation`](/orm/prisma-schema/data-model/relations#the-relation-attribute) attribute if it's not needed. Consider the `User` ↔ `Post` example from the previous section. The `@relation` attribute only has the `references` argument, `name` is omitted because it's not needed in this case: +Prisma ORM generally omits the `name` argument on the [`@relation`](/orm/prisma-schema/data-model/relations#the-relation-attribute) attribute if it's not needed. Consider the `User` ↔ `Post` example from the previous section. The `@relation` attribute only has the `references` argument, `name` is omitted because it's not needed in this case: ```prisma model Post { @@ -294,7 +294,7 @@ CREATE TABLE "Post" ( ); ``` -In this case, Prisma needs to [disambiguate the relation](/orm/prisma-schema/data-model/relations#disambiguating-relations) using a dedicated relation name: +In this case, Prisma ORM needs to [disambiguate the relation](/orm/prisma-schema/data-model/relations#disambiguating-relations) using a dedicated relation name: ```prisma model Post { @@ -312,7 +312,7 @@ model User { } ``` -Note that you can rename the [Prisma-level](/orm/prisma-schema/data-model/relations#relation-fields) relation field to anything you like so that it looks friendlier in the generated Prisma Client API. +Note that you can rename the [Prisma-ORM level](/orm/prisma-schema/data-model/relations#relation-fields) relation field to anything you like so that it looks friendlier in the generated Prisma Client API. ## Introspection with an existing schema @@ -325,8 +325,8 @@ Introspection for relational databases maintains the following manual changes: - Comments - `@map` and `@@map` attributes - `@updatedAt` -- `@default(cuid())` (`cuid()` is a Prisma-level function) -- `@default(uuid())` (`uuid()` is a Prisma-level function) +- `@default(cuid())` (`cuid()` is a Prisma-ORM level function) +- `@default(uuid())` (`uuid()` is a Prisma-ORM level function) - Custom `@relation` names > **Note**: Only relations between models on the database level will be picked up. This means that there **must be a foreign key set**. @@ -353,7 +353,7 @@ Use cases include: ## Introspecting only a subset of your database schema -Introspecting only a subset of your database schema is [not yet officially supported](https://github.com/prisma/prisma/issues/807) by Prisma. +Introspecting only a subset of your database schema is [not yet officially supported](https://github.com/prisma/prisma/issues/807) by Prisma ORM. However, you can achieve this by creating a new database user that only has access to the tables which you'd like to see represented in your Prisma schema, and then perform the introspection using that user. The introspection will then only include the tables the new user has access to. @@ -361,7 +361,7 @@ If your goal is to exclude certain models from the [Prisma Client generation](/o ## Introspection warnings for unsupported features -The Prisma Schema Language (PSL) can express a majority of the database features of the [target databases](/orm/reference/supported-databases) Prisma supports. However, there are features and functionality the Prisma Schema Language still needs to express. +The Prisma Schema Language (PSL) can express a majority of the database features of the [target databases](/orm/reference/supported-databases) Prisma ORM supports. However, there are features and functionality the Prisma Schema Language still needs to express. For these features, the Prisma CLI will surface detect usage of the feature in your database and return a warning. The Prisma CLI will also add a comment in the models and fields the features are in use in the Prisma schema. The warnings will also contain a workaround suggestion. 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 dd7b3cfb9d..03f9e72d59 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 @@ -28,7 +28,7 @@ The setup instructions [below](#set-up) provide a high-level overview of the ste type="primary" href="/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql" > - Add Prisma to an existing project + Add Prisma ORM to an existing project @@ -135,7 +135,7 @@ const prisma = new PrismaClient() For Deno, you can import Prisma Client as follows: ```ts file=lib/prisma.ts -import { PrismaClient } from '../prisma/generated/client/edge.ts' +import { PrismaClient } from './generated/client/deno/edge.ts' const prisma = new PrismaClient() // use `prisma` in your application to read and write data in your DB 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 8c5d3ef03c..45ff651ab0 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 @@ -35,7 +35,7 @@ const prisma = new PrismaClient() -You can further customize `PrismaClient` with [constructor parameters](/orm/reference/prisma-client-reference#prismaclient) - for example, set [logging levels](/orm/prisma-client/observability-and-logging/logging) or customize [error formatting](error-formatting). +You can further customize `PrismaClient` with [constructor parameters](/orm/reference/prisma-client-reference#prismaclient) — for example, set [logging levels](/orm/prisma-client/observability-and-logging/logging), [transaction options](/orm/prisma-client/queries/transactions#transaction-options) or customize [error formatting](error-formatting). @@ -43,11 +43,11 @@ You can further customize `PrismaClient` with [constructor parameters](/orm/refe ## The number of `PrismaClient` instances matters -Your application should generally only create **one instance** of `PrismaClient`. How to achieve this depends on whether you are using Prisma in a [long-running application](/orm/prisma-client/setup-and-configuration/databases-connections#prismaclient-in-long-running-applications) or in a [serverless environment](/orm/prisma-client/setup-and-configuration/databases-connections#prismaclient-in-serverless-environments) . +Your application should generally only create **one instance** of `PrismaClient`. How to achieve this depends on whether you are using Prisma ORM in a [long-running application](/orm/prisma-client/setup-and-configuration/databases-connections#prismaclient-in-long-running-applications) or in a [serverless environment](/orm/prisma-client/setup-and-configuration/databases-connections#prismaclient-in-serverless-environments) . The reason for this is that each instance of `PrismaClient` manages a connection pool, which means that a large number of clients can **exhaust the database connection limit**. This applies to all database connectors. -If you use the **MongoDB connector**, connections are managed by the MongoDB driver connection pool. If you use a **relational database connector**, connections are managed by Prisma's [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool). Each instance of `PrismaClient` creates its own pool. +If you use the **MongoDB connector**, connections are managed by the MongoDB driver connection pool. If you use a **relational database connector**, connections are managed by Prisma ORM's [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool). Each instance of `PrismaClient` creates its own pool. 1. Each client creates its own instance of the [query engine](/orm/more/under-the-hood/engines). 1. Each query engine creates a [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) with a default pool size of: 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 1475529552..bf70b7c253 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 @@ -87,11 +87,11 @@ If the above script runs multiple times in the context of a long-running applica -From Prisma 5.0.0, the `beforeExit` hook only applies to the [binary Query Engine](/orm/more/under-the-hood/engines#configuring-the-query-engine). +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 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: +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: ```ts const prisma = new PrismaClient() 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 54e52841b6..858cba7ae6 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 @@ -1,6 +1,6 @@ --- title: Connection pool -metaDescription: Prisma's query engine creates a connection pool to store and manage database connections. +metaDescription: Prisma ORM's query engine creates a connection pool to store and manage database connections. tocDepth: 4 --- @@ -11,13 +11,13 @@ The query engine manages a **connection pool** of database connections. The pool - By [explicitly calling `$connect()`](connection-management#connect) _or_ - By running the first query, which calls `$connect()` under the hood -Relational database connectors use Prisma's own connection pool, and the MongoDB connectors uses the [MongoDB driver connection pool](https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst). +Relational database connectors use Prisma ORM's own connection pool, and the MongoDB connectors uses the [MongoDB driver connection pool](https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst). ## Relational databases -The relational database connectors use Prisma's connection pool. The connection pool has a **connection limit** and a **pool timeout**, which are controlled by connection URL parameters. +The relational database connectors use Prisma ORM's connection pool. The connection pool has a **connection limit** and a **pool timeout**, which are controlled by connection URL parameters. ### How the connection pool works @@ -204,7 +204,7 @@ You can choose to [disable the connection pool timeout if queries **must** remai ## MongoDB -The MongoDB connector does not use the Prisma connection pool. The connection pool is managed internally by the MongoDB driver and [configured via connection string parameters](https://docs.mongodb.com/manual/reference/connection-string/#connection-pool-options). +The MongoDB connector does not use the Prisma ORM connection pool. The connection pool is managed internally by the MongoDB driver and [configured via connection string parameters](https://docs.mongodb.com/manual/reference/connection-string/#connection-pool-options). ## External connection poolers @@ -214,4 +214,4 @@ Consider introducing [an external connection pooler like PgBouncer](/orm/prisma- ## Manual database connection handling -When using Prisma, the database connections are handled on an [engine](https://github.com/prisma/prisma-engines)-level. This means they're not exposed to the developer and it's not possible to manually access them. +When using Prisma ORM, the database connections are handled on an [engine](https://github.com/prisma/prisma-engines)-level. This means they're not exposed to the developer and it's not possible to manually access them. diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/200-pgbouncer.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/200-pgbouncer.mdx index 49935e6d9c..fecd54f826 100644 --- a/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/200-pgbouncer.mdx +++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/050-databases-connections/200-pgbouncer.mdx @@ -7,7 +7,7 @@ metaTitle: Configure Prisma Client with PgBouncer An external connection pooler like PgBouncer holds a connection pool to the database, and proxies incoming client connections by sitting between Prisma Client and the database. This reduces the number of processes a database has to handle at any given time. -Usually, this works transparently, but some connection poolers only support a limited set of functionality. One common feature that external connection poolers do not support are named prepared statements, which Prisma uses. For these cases, Prisma can be configured to behave differently. +Usually, this works transparently, but some connection poolers only support a limited set of functionality. One common feature that external connection poolers do not support are named prepared statements, which Prisma ORM uses. For these cases, Prisma ORM can be configured to behave differently. @@ -30,12 +30,12 @@ postgresql://USER:PASSWORD@HOST:PORT/DATABASE?pgbouncer=true > Note: `PORT` specified for PgBouncer pooling is sometimes different from the default `5432` port. Check your database provider docs for the correct port number.
- How `pgbouncer` mode works in Prisma + How `pgbouncer` mode works in Prisma ORM -- Prisma opens a transaction for every query – even when just reading data, allowing Prisma to use prepared statements. -- Prisma does not try to set the `search_path`, which is not supported by PgBouncer. -- Prisma cleans up already present prepared statements in the connection by running `DEALLOCATE ALL` before preparing and executing Prisma Client queries. -- Prisma also disables any prepared statement or type query caches. +- Prisma ORM opens a transaction for every query – even when just reading data, allowing Prisma to use prepared statements. +- Prisma ORM does not try to set the `search_path`, which is not supported by PgBouncer. +- Prisma ORM cleans up already present prepared statements in the connection by running `DEALLOCATE ALL` before preparing and executing Prisma Client queries. +- Prisma ORM also disables any prepared statement or type query caches.
@@ -62,7 +62,7 @@ datasource db { The block above uses a PgBouncer connection string as the primary URL using `url`, allowing Prisma Client to take advantage of the PgBouncer connection pooler. -It also provides a connection string directly to the database, without PgBouncer, using the `directUrl` field. This connection string will be used when [commands that require a single connection](/platform/classic-projects/data-proxy/prisma-cli-with-data-proxy#prisma-cli-commands-that-require-a-direct-database-connection) to the database, such as `prisma migrate dev` or `prisma db push`, are invoked. +It also provides a connection string directly to the database, without PgBouncer, using the `directUrl` field. This connection string will be used when commands that require a single connection to the database, such as `prisma migrate dev` or `prisma db push`, are invoked. ### PgBouncer with different database providers @@ -75,8 +75,8 @@ Below are links to information on how to set up these connections with providers ## Supabase Supavisor -Supabase's Supavisor behaves similar to [PgBouncer](#pgbouncer). You can add `pgbouncer=true` to your connection pooled connection string. +Supabase's Supavisor behaves similarly to [PgBouncer](#pgbouncer). You can add `?pgbouncer=true` to your connection pooled connection string available via your [Supabase database settings](https://supabase.com/dashboard/project/_/settings/database). ## Other external connection poolers -Although Prisma does not have explicit support for other connection poolers, if the limitations are similar to the ones of [PgBouncer](#pgbouncer) you can usually also use `pgbouncer=true` in your connection string to put Prisma in a mode that works with them as well. +Although Prisma ORM does not have explicit support for other connection poolers, if the limitations are similar to the ones of [PgBouncer](#pgbouncer) you can usually also use `pgbouncer=true` in your connection string to put Prisma ORM in a mode that works with them as well. 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 892b207df4..89228fc79f 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 @@ -16,7 +16,7 @@ The way your application **manages connections** also impacts performance. This -This guide focuses on **relational databases** and how to configure and tune the Prisma connection pool (MongoDB uses the MongoDB driver connection pool). +This guide focuses on **relational databases** and how to configure and tune the Prisma ORM connection pool (MongoDB uses the MongoDB driver connection pool). @@ -233,7 +233,7 @@ Code should assume the container to be stateless and create a connection only if Containers that are marked "to be removed" and are not being reused still **keep a connection open** and can stay in that state for some time (unknown and not documented from AWS). This can lead to sub-optimal utilization of the database connections. -A potential solution is to **clean up idle connections** ([`serverless-mysql`](https://github.com/jeremydaly/serverless-mysql) implements this idea, but cannot be used with Prisma). +A potential solution is to **clean up idle connections** ([`serverless-mysql`](https://github.com/jeremydaly/serverless-mysql) implements this idea, but cannot be used with Prisma ORM). #### Concurrency limits @@ -298,7 +298,7 @@ datasource db { ## External connection poolers -Connection poolers like the Data Proxy and PgBouncer prevent your application from exhausting the database's connection limit. +Connection poolers like [Prisma Accelerate](/accelerate) and PgBouncer prevent your application from exhausting the database's connection limit. If you would like to use the Prisma CLI in order to perform other actions on your database ,e.g. migrations and introspection, you will need to add an environment variable that provides a direct connection to your database in the `datasource.directUrl` property in your Prisma schema: @@ -322,9 +322,9 @@ datasource db { More information about the `directUrl` field can be found [here](/orm/reference/prisma-schema-reference#fields). -### Data Proxy +### Prisma Accelerate -The [Data Proxy](/platform/classic-projects/data-proxy) is a managed external connection pooler built by Prisma that is integrated in the [Prisma Data Platform](/platform) and handles connection pooling for you. +[Prisma Accelerate](/accelerate) is a managed external connection pooler built by Prisma that is integrated in the [Prisma Data Platform](/platform) and handles connection pooling for you. ### PgBouncer diff --git a/content/200-orm/200-prisma-client/000-setup-and-configuration/100-custom-model-and-field-names.mdx b/content/200-orm/200-prisma-client/000-setup-and-configuration/100-custom-model-and-field-names.mdx index a60eb98ed9..ed8ea044e4 100644 --- a/content/200-orm/200-prisma-client/000-setup-and-configuration/100-custom-model-and-field-names.mdx +++ b/content/200-orm/200-prisma-client/000-setup-and-configuration/100-custom-model-and-field-names.mdx @@ -93,9 +93,9 @@ model users { There are a few "issues" with this Prisma schema when the Prisma Client API is generated: -**Adhering to Prisma's naming conventions** +**Adhering to Prisma ORM's naming conventions** -Prisma has a [naming convention](/orm/reference/prisma-schema-reference#naming-conventions) of **camelCasing** and using the **singular form** for Prisma models. If these naming conventions are not met, the Prisma schema can become harder to interpret and the generated Prisma Client API will feel less natural. Consider the following, generated model: +Prisma ORM has a [naming convention](/orm/reference/prisma-schema-reference#naming-conventions) of **camelCasing** and using the **singular form** for Prisma models. If these naming conventions are not met, the Prisma schema can become harder to interpret and the generated Prisma Client API will feel less natural. Consider the following, generated model: ```prisma model users { @@ -107,7 +107,7 @@ model users { } ``` -Although `profiles` refers to a 1:1 relation, its type is currently called `profiles` in plural, suggesting that there might be many `profiles` in this relation. With Prisma conventions, the models and fields were _ideally_ named as follows: +Although `profiles` refers to a 1:1 relation, its type is currently called `profiles` in plural, suggesting that there might be many `profiles` in this relation. With Prisma ORM conventions, the models and fields were _ideally_ named as follows: ```prisma model User { @@ -119,7 +119,7 @@ model User { } ``` -Because these fields are "Prisma-level" [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) that do not manifest you can manually rename them in your Prisma schema. +Because these fields are "Prisma ORM-level" [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) that do not manifest you can manually rename them in your Prisma schema. **Naming of annotated relation fields** @@ -224,7 +224,7 @@ model User { } ``` -With these changes, you're now adhering to Prisma's naming conventions and the generated Prisma Client API feels more "natural": +With these changes, you're now adhering to Prisma ORM's naming conventions and the generated Prisma Client API feels more "natural": ```ts // Nested writes @@ -250,7 +250,7 @@ const userByProfile = await prisma.profile ## Renaming relation fields -Prisma-level [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) (sometimes referred to as "virtual relation fields") only exist in the Prisma schema, but do not actually manifest in the underlying database. You can therefore name these fields whatever you want. +Prisma ORM-level [relation fields](/orm/prisma-schema/data-model/relations#relation-fields) (sometimes referred to as "virtual relation fields") only exist in the Prisma schema, but do not actually manifest in the underlying database. You can therefore name these fields whatever you want. Consider the following example of an ambiguous relation in a SQL database: @@ -267,7 +267,7 @@ CREATE TABLE "Post" ( ); ``` -Prisma's introspection will output the following Prisma schema: +Prisma ORM's introspection will output the following Prisma schema: ```prisma model Post { 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 0d73fbb82b..e9dc28d626 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 @@ -9,7 +9,7 @@ tocDepth: 3 Read replicas enable you to distribute workloads across database replicas for high-traffic workloads. The [read replicas extension](https://github.com/prisma/extension-read-replicas), `@prisma/extension-read-replicas`, adds support for read-only database replicas to Prisma Client. -The read replicas extension supports Prisma versions [5.2.0](https://github.com/prisma/prisma/releases/tag/5.2.0) and higher. If you run into a bug or have feedback, create a GitHub issue [here](https://github.com/prisma/extension-read-replicas/issues/new). +The read replicas extension supports Prisma ORM versions [5.2.0](https://github.com/prisma/prisma/releases/tag/5.2.0) and higher. If you run into a bug or have feedback, create a GitHub issue [here](https://github.com/prisma/extension-read-replicas/issues/new). 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 2a06472fb0..4f791530fe 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 @@ -681,11 +681,11 @@ const upsertUser = await prisma.user.upsert({ -From version 4.6.0, Prisma carries out upserts with database native SQL commands where possible. [Learn more](/orm/reference/prisma-client-reference#database-upserts). +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 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`. +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`. diff --git a/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx b/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx index bff0b2dddc..1ba2a43dc2 100644 --- a/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx +++ b/content/200-orm/200-prisma-client/100-queries/035-select-fields.mdx @@ -19,6 +19,8 @@ To customize the result: Selecting only the fields and relations that you require rather than relying on the default selection set can ✔ reduce the size of the response and ✔ improve query speed. +Since version [5.9.0](https://github.com/prisma/prisma/releases/tag/5.9.0), when doing a relation query with `include` or by using `select` on a relation field, you can also specify the `relationLoadStrategy` to decide whether you want to use a database-level join or perform multiple queries and merge the data on the application level. This feature is currently in [Preview](/orm/more/releases#preview), you can learn more about it [here](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview). + ## Example schema 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 3f35b80526..a6c9b82673 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 @@ -24,6 +24,64 @@ Nested reads allow you to read related data from multiple tables in your databas - Use [`include`](/orm/reference/prisma-client-reference#include) to include related records, such as a user's posts or profile, in the query response. - Use a nested [`select`](/orm/reference/prisma-client-reference#select) to include specific fields from a related record. You can also nest `select` inside an `include`. +### Relation load strategies (Preview) + +Since version [5.9.0](https://github.com/prisma/prisma/releases/tag/5.9.0), you can decide on a per-query-level _how_ you want Prisma Client to execute a relation query (i.e. what _load strategy_ should be applied) via the `relationLoadStrategy` option. + +Because the `relationLoadStrategy` option is currently in Preview, you need to enable it via the `relationJoins` preview feature flag in your Prisma schema file: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["relationJoins"] +} +``` + +After adding this flag, you need to run `prisma generate` again to re-generate Prisma Client. This feature is currently available on PostgreSQL, CockroachDB and MySQL. + +Prisma Client supports two load strategies for relations: + +- `join` (default): Uses a database-level `LATERAL JOIN` (PostgreSQL) or correlated subqueries (MySQL) and fetches all data with a single query to the database. +- `query`: Sends multiple queries to the database (one per table) and joins them on the application level. + +Another important difference between these two options is that the `join` strategy uses JSON aggregation on the database level. That means that it creates the JSON structures returned by Prisma Client already in the database which saves computation resources on the application level. + +> **Note**: Once `relationLoadStrategy` moves from [Preview](/orm/more/releases#preview) into [General Availability](/orm/more/releases/#generally-available-ga), `join` will universally become the default for all relation queries. + +#### Examples + +You can use the `relationLoadStrategy` option on the top-level in any query that supports `include` or `select`. + +Here is an example with `include`: + +```ts +const users = await prisma.user.findMany({ + relationLoadStrategy: 'join', // or 'query' + include: { + posts: true, + }, +}) +``` + +And here is another example with `select`: + +```ts +const users = await prisma.user.findMany({ + relationLoadStrategy: 'join', // or 'query' + select: { + posts: true, + }, +}) +``` + +#### When to use which load strategy? + +- The `join` strategy (default) will be more effective in most scenarios. On PostgreSQL, it uses a combination of `LATERAL JOINs` and JSON aggregation to reduce redundancy in result sets and delegate the work of transforming the query results into the expected JSON structures on the database server. On MySQL, it uses correlated subqueries to fetch the results with a single query. +- There may be edge cases where `query` could be more performant depending on the characteristics of the dataset and query. We recommend that you profile your database queries to identify these situations. +- Use `query` if you want to save resources on the database server and do heavy-lifting of merging and transforming data in the application server which might be easier to scale. + +### Include a relation + The following example returns a single user and that user's posts: @@ -1227,7 +1285,7 @@ const postsByUser = await prisma.post.findMany({ The main difference between the queries is that the fluent API call is translated into two separate database queries while the other one only generates a single query (see this [GitHub issue](https://github.com/prisma/prisma/issues/1984)) -> **Note**: You can use the fact that `.findUnique({ where: { email: 'alice@prisma.io' } }).posts()` queries are automatically batched by the Prisma dataloader to [avoid the n+1 problem in GraphQL resolvers](/orm/prisma-client/queries/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prismas-dataloader). +> **Note**: You can use the fact that `.findUnique({ where: { email: 'alice@prisma.io' } }).posts()` queries are automatically batched by the Prisma dataloader in Prisma Client to [avoid the n+1 problem in GraphQL resolvers](/orm/prisma-client/queries/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prisma-clients-dataloader). This request returns all categories by a specific post: diff --git a/content/200-orm/200-prisma-client/100-queries/055-pagination.mdx b/content/200-orm/200-prisma-client/100-queries/055-pagination.mdx index 25627e6d40..a73c454569 100644 --- a/content/200-orm/200-prisma-client/100-queries/055-pagination.mdx +++ b/content/200-orm/200-prisma-client/100-queries/055-pagination.mdx @@ -160,7 +160,7 @@ No, cursor pagination does not use cursors in the underlying database ([e.g. Pos #### What happens if the cursor value does not exist? -Using a nonexistent cursor returns `null`. Prisma does not try to locate adjacent values. +Using a nonexistent cursor returns `null`. Prisma Client does not try to locate adjacent values. ### ✔ Pros of cursor-based pagination 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 3011a2078d..6b59303b93 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 @@ -260,7 +260,7 @@ The following constraints apply when you combine `groupBy` and `orderBy`: #### Order by aggregate group -You can **order by aggregate group**. Prisma added support for using `orderBy with aggregated groups in relational databases in version [2.21.0](https://github.com/prisma/prisma/releases/2.21.0) and support for MongoDB in [3.4.0](https://github.com/prisma/prisma/releases/3.4.0). +You can **order by aggregate group**. Prisma ORM added support for using `orderBy with aggregated groups in relational databases in version [2.21.0](https://github.com/prisma/prisma/releases/2.21.0) and support for MongoDB in [3.4.0](https://github.com/prisma/prisma/releases/3.4.0). The following example sorts each `city` group by the number of users in that group (largest group first): @@ -329,7 +329,9 @@ Both `distinct` and `groupBy` group records by one or more unique field values. ## Count -Use [`count`](/orm/reference/prisma-client-reference#count) to count the number of records or non-`null` field values. The following example query counts all users: +### Count records + +Use [`count()`](/orm/reference/prisma-client-reference#count) to count the number of records or non-`null` field values. The following example query counts all users: ```ts const userCount = await prisma.user.count() @@ -337,12 +339,9 @@ const userCount = await prisma.user.count() ### Count relations -The ability to count relations is available in version [3.0.1](https://github.com/prisma/prisma/releases/3.0.1) and later. - -**For versions before 3.0.1**
-You need to add the [preview feature](/orm/reference/preview-features/client-preview-features#enabling-a-prisma-client-preview-feature) `selectRelationCount` and then run `prisma generate`. +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.
@@ -380,7 +379,7 @@ The `_count` parameter: - Can be used inside a top-level `include` _or_ `select` - Can be used with any query that returns records (including `delete`, `update`, and `findFirst`) - Can return [multiple relation counts](#return-multiple-relation-counts) -- From version 4.3.0, can [filter relation counts](#filter-the-relation-count) +- Can [filter relation counts](#filter-the-relation-count) (from version 4.3.0) #### Return a relations count with include @@ -415,7 +414,7 @@ const usersWithCount = await prisma.user.findMany({ #### Return a relations count with `select` -The following query uses `select` to return each user's post count and no other fields: +The following query uses `select` to return each user's post count _and no other fields_: @@ -621,7 +620,7 @@ const distinctRoles = await prisma.user.findMany({ ### distinct under the hood -Prisma's `distinct` option does not use SQL `SELECT DISTINCT`. Instead, `distinct` uses: +Prisma Client's `distinct` option does not use SQL `SELECT DISTINCT`. Instead, `distinct` uses: - A `SELECT` query - In-memory post-processing to select distinct 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 a3b7b9d153..844f4ef8e1 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 @@ -9,16 +9,13 @@ tocDepth: 3 A database transaction refers to a sequence of read/write operations that are _guaranteed_ to either succeed or fail as a whole. This section describes the ways in which the Prisma Client API supports transactions. -- For more in-depth examples and use cases, refer to the 📖 [transactions guide](/orm/prisma-client/queries/transactions). -- For information about transactions in general and the reasoning behind Prisma's current solutions, see [Blog: How Prisma supports transactions](https://www.prisma.io/blog/how-prisma-supports-transactions-x45s1d5l0ww1). - ## Transactions overview -Before Prisma version 4.4.0, you could not set isolation levels on transactions. The isolation level in your database configuration always applied. +Before Prisma ORM version 4.4.0, you could not set isolation levels on transactions. The isolation level in your database configuration always applied. @@ -45,9 +42,9 @@ The technique you choose depends on your particular use case. > **Note**: For the purposes of this guide, _writing_ to a database encompasses creating, updating, and deleting data. -## About transactions in Prisma +## About transactions in Prisma Client -Prisma provides the following options for using transactions: +Prisma Client provides the following options for using transactions: - [Nested writes](#nested-writes): use the Prisma Client API to process multiple operations on one or more related records inside the same transaction. - [Batch / bulk transactions](#batchbulk-operations): process one or more operations in bulk with `updateMany`, `deleteMany`, and `createMany`. @@ -91,8 +88,6 @@ const updatedPost: Post = await prisma.post.update({ }) ``` -> Refer to the 📖 [transactions guide](/orm/prisma-client/queries/transactions#nested-writes) for more examples. - ## Batch/bulk operations The following bulk operations run as transactions: @@ -101,7 +96,7 @@ The following bulk operations run as transactions: - `updateMany` - `createMany` -> Refer to the 📖 [transactions guide](/orm/prisma-client/queries/transactions#bulk-operations) for more examples. +> Refer to the section about [bulk operations](#bulk-operations) for more examples. ## The $transaction API @@ -174,7 +169,7 @@ Instead of immediately awaiting the result of each operation when it's performed > **Note**: Operations are executed according to the order they are placed in the transaction. Using a query in a transaction does not influence the order of operations in the query itself. > -> Refer to the 📖 [transactions guide](/orm/prisma-client/queries/transactions#transaction-api) for more examples. +> Refer to the secction about the [transactions API](#transaction-api) for more examples. From version 4.4.0, the sequential operations transaction API has a second parameter. You can use the following optional configuration option in this parameter: @@ -196,23 +191,29 @@ await prisma.$transaction( ### Interactive transactions +#### Overview + Sometimes you need more control over what queries execute within a transaction. Interactive transactions are meant to provide you with an escape hatch. -Interactive transactions are available in the following versions of Prisma: - -- Interactive transactions are generally available from version 4.7.0. -- In version 4.6, Data Proxy support for interactive transactions was available in preview. -- From version 2.29.0 to version 4.5, interactive transactions were available in preview, but did not support the [Data Proxy](/platform/classic-projects/data-proxy). +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 (included), 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`](/orm/prisma-client/queries/transactions#transaction-api). +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. + + -The first argument passed into this async function is an instance of Prisma Client. Below, we will call this instance `tx`. Any Prisma call invoked on this `tx` instance is encapsulated into the transaction. +**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 Let's look at an example: @@ -294,6 +295,8 @@ try { } ``` +#### Transaction options + The transaction API has a second parameter. For interactive transactions, you can use the following optional configuration options in this parameter: - `maxWait`: The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds. @@ -302,7 +305,7 @@ The transaction API has a second parameter. For interactive transactions, you ca For example: -```jsx +```ts await prisma.$transaction( async (tx) => { // Code running in a transaction... @@ -315,14 +318,17 @@ await prisma.$transaction( ) ``` - +You can also set these globally on the constructor-level: -**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! - - +```ts +const prisma = new PrismaClient({ + transactionOptions: { + isolationLevel: Prisma.TransactionIsolationLevel.Serializable, + maxWait: 5000, // default: 2000 + timeout: 10000, // default: 5000 + }, +}) +``` ### Transaction isolation level @@ -336,9 +342,9 @@ You can set the transaction [isolation level](https://www.prisma.io/dataguide/in -This is available in the following Prisma versions for interactive transactions from version 4.2.0, for sequential operations from version 4.4.0. +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 level. Prisma does not explicitly set the isolation level, so the [isolation level configured in your database](#database-specific-information-on-isolation-levels) is used. +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. @@ -497,7 +503,7 @@ Dependent writes must succeed together in order to maintain data consistency and ### Nested writes -Prisma's solution to dependent writes is the **nested writes** feature, which is supported by `create` and `update`. The following nested write creates one user and two blog posts: +Prisma Client's solution to dependent writes is the **nested writes** feature, which is supported by `create` and `update`. The following nested write creates one user and two blog posts: ```ts const nestedWrite = await prisma.user.create({ @@ -513,7 +519,7 @@ const nestedWrite = await prisma.user.create({ }) ``` -If any operation fails, Prisma rolls back the entire transaction. Nested writes are not currently supported by top-level bulk operations like `client.user.deleteMany` and `client.user.updateMany`. +If any operation fails, Prisma Client rolls back the entire transaction. Nested writes are not currently supported by top-level bulk operations like `client.user.deleteMany` and `client.user.updateMany`. #### When to use nested writes @@ -736,7 +742,7 @@ Depending on your requirements, Prisma Client has four options for handling inde ### Bulk operations -Bulk writes allow you to write multiple records of the same type in a single transaction - if any operation fails, Prisma rolls back the entire transaction. Prisma currently supports: +Bulk writes allow you to write multiple records of the same type in a single transaction - if any operation fails, Prisma Client rolls back the entire transaction. Prisma Client currently supports: - `updateMany` - `deleteMany` @@ -806,11 +812,11 @@ await prisma.team.deleteMany({ #### Can I use bulk operations with the `$transaction([])` API? -Yes - for example, you can include multiple `deleteMany` operations inside a `$transaction([])`. +Yes — for example, you can include multiple `deleteMany` operations inside a `$transaction([])`. ### $transaction([]) API -The `$transaction([])` API is generic solution to independent writes that allows you to run multiple operations as a single, atomic operation - if any operation fails, Prisma rolls back the entire transaction. +The `$transaction([])` API is generic solution to independent writes that allows you to run multiple operations as a single, atomic operation - if any operation fails, Prisma Client rolls back the entire transaction. Its also worth noting that operations are executed according to the order they are placed in the transaction. @@ -1265,7 +1271,7 @@ If you have an existing application, it can be a significant undertaking to refa To create an interactive transaction, 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 call invoked on this `tx` instance is encapsulated into the transaction. +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. In the example below, Alice and Bob each have $100 in their account. If they try to send more money than they have, the transfer is rejected. @@ -1324,7 +1330,7 @@ In the example above, both `update` queries run within a database transaction. W If the application encounters an error along the way, the async function will throw an exception and automatically **rollback** the transaction. -You can learn more about interactive transactions in our [Transactions and Batch Queries documentation](/orm/prisma-client/queries/transactions#interactive-transactions). +You can learn more about interactive transactions in this [section](#interactive-transactions). @@ -1337,4 +1343,4 @@ transaction functions. We recommend you get in and out as quick as possible! ## Conclusion -Prisma supports multiple ways of handling transactions, either directly through the API or by supporting your ability to introduce optimistic concurrency control and idempotency into your application. If you feel like you have use cases in your application that are not covered by any of the suggested options, please open a [GitHub issue](https://github.com/prisma/prisma/issues/new/choose) to start a discussion. +Prisma Client supports multiple ways of handling transactions, either directly through the API or by supporting your ability to introduce optimistic concurrency control and idempotency into your application. If you feel like you have use cases in your application that are not covered by any of the suggested options, please open a [GitHub issue](https://github.com/prisma/prisma/issues/new/choose) to start a discussion. 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 7e622911d7..931d9e793b 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 @@ -9,6 +9,8 @@ preview: true Prisma Client supports full-text search for **PostgreSQL** databases in versions 2.30.0 and later, and **MySQL** databases in versions 3.8.0 and later. With full-text search enabled, you can add search functionality to your application by searching for text within a database column. +> **Note**: There currently is a [known issue](https://github.com/prisma/prisma/issues/23627) in the full-text search feature. If you observe slow search queries, you can [optimize your query with raw SQL](#full-text-search-with-raw-sql). + ## Enabling full-text search @@ -174,7 +176,7 @@ Sorting by relevance is only available for PostgreSQL and MySQL. -In addition to [Prisma'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: +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: ```ts const posts = await prisma.post.findMany({ @@ -243,3 +245,37 @@ const result = await prisma.blogs.findMany({ ``` However, if you try to search on `title` alone, the search will fail with the error "Cannot find a fulltext index to use for the search" and the message code is `P2030`, because the index requires a search on both fields. + +## Full-text search with raw SQL + +Full-text search is currently in Preview and due to a [known issue](https://github.com/prisma/prisma/issues/23627), you may be seeing slow search queries. If that's the case, you can optimize your query using [raw SQL](/orm/prisma-client/queries/raw-database-access). + +### PostgreSQL + +In PostgreSQL, you can use `to_tsvector` and `to_tsquery` to express your search query: + +```ts +const term = `cat` +const result = + await prisma.$queryRaw`SELECT * FROM "Blog" WHERE to_tsvector('english', "Blog"."content") @@ to_tsquery('english', ${term});` +``` + +> **Note**: Depending on your language preferences, you may exchange `english` against another language in the SQL statement. + +If you want to include a wildcard in your search term, you can do this as follows: + +```ts +const term = `cat:*` +const result = + await prisma.$queryRaw`SELECT * FROM "Blog" WHERE to_tsvector('english', "Blog"."content") @@ to_tsquery('english', ${term});` +``` + +### MySQL + +In MySQL, you can express your search query as follows: + +```ts +const term = `cat` +const result = + await prisma.$queryRaw`SELECT * FROM Blog WHERE MATCH(content) AGAINST(${term} IN NATURAL LANGUAGE MODE);` +``` diff --git a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/050-raw-queries.mdx b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/050-raw-queries.mdx index b836c79d1d..ab387932a2 100644 --- a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/050-raw-queries.mdx +++ b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/050-raw-queries.mdx @@ -12,7 +12,7 @@ Prisma Client supports the option of sending raw queries to your database. You m - you want to run a heavily optimized query - you require a feature that Prisma Client does not yet support (please [consider raising an issue](https://github.com/prisma/prisma/issues/new/choose)) -Raw queries are available for all relational databases Prisma supports. In addition, from version `3.9.0` raw queries are supported in MongoDB. For more details, see the relevant sections: +Raw queries are available for all relational databases Prisma ORM supports. In addition, from version `3.9.0` raw queries are supported in MongoDB. For more details, see the relevant sections: - [Raw queries with relational databases](#raw-queries-with-relational-databases) - [Raw queries with MongoDB](#raw-queries-with-mongodb) @@ -23,10 +23,16 @@ Raw queries are available for all relational databases Prisma supports. In addit For relational databases, Prisma Client exposes four methods that allow you to send raw queries. You can use: -- `$queryRaw` to return actual records (for example, using `SELECT`) -- `$executeRaw` to return a count of affected rows (for example, after an `UPDATE` or `DELETE`) -- `$queryRawUnsafe` to return actual records (for example, using `SELECT`) using a raw string. **Potential SQL injection risk** -- `$executeRawUnsafe` to return a count of affected rows (for example, after an `UPDATE` or `DELETE`) using a raw string. **Potential SQL injection risk** +- `$queryRaw` to return actual records (for example, using `SELECT`). +- `$executeRaw` to return a count of affected rows (for example, after an `UPDATE` or `DELETE`). +- `$queryRawUnsafe` to return actual records (for example, using `SELECT`) using a raw string. +- `$executeRawUnsafe` to return a count of affected rows (for example, after an `UPDATE` or `DELETE`) using a raw string. + +The methods with "Unsafe" in the name are a lot more flexible but are at **significant risk of making your code vulnerable to SQL injection**. + +The other two methods are safe to use with a simple template tag, no string building, and no concatenation. **However**, caution is required for more complex use cases as it is still possible to introduce SQL injection if these methods are used in certain ways. For more details, see the [SQL injection prevention](#sql-injection-prevention) section below. + +> **Note**: All methods in the above list can only run **one** query at a time. You cannot append a second query - for example, calling any of them with `select 1; select 2;` will not work. ### $queryRaw @@ -36,7 +42,7 @@ For relational databases, Prisma Client exposes four methods that allow you to s const result = await prisma.$queryRaw`SELECT * FROM User` ``` -The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma creates prepared statements that are safe from SQL injections: +The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma Client creates prepared statements that are safe from SQL injections: ```ts no-lines const email = 'emelie@prisma.io' @@ -52,6 +58,12 @@ const result = await prisma.$queryRaw( ) ``` + + +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 prefered 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 Be aware that: @@ -151,7 +163,7 @@ result.forEach((x) => { }) ``` -> **Note**: The Prisma Client query engine standardizes the return type for all databases. **Using the raw queries does not**. If the database provider is MySQL, the values are `1` or `0`. However, if the database provider is PostgreSQL, the values are `true`, `false`, or `NULL`. +For regular CRUD queries, the Prisma Client query engine standardizes the return type for all databases. **Using the raw queries does not**. If the database provider is MySQL, the returned values are `1` or `0`. However, if the database provider is PostgreSQL, the values are `true` or `false`. > **Note**: Prisma sends JavaScript integers to PostgreSQL as `INT8`. This might conflict with your user-defined functions that accept only `INT4` as input. If you use `$queryRaw` in conjunction with a PostgreSQL database, update the input types to `INT8`, or cast your query parameters to `INT4`. @@ -174,7 +186,7 @@ The `$queryRawUnsafe` method allows you to pass a raw string (or template string 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.

-We strongly advise that you use the `$queryRaw` query instead. For more information on SQL injection attacks, see the [OWASP SQL Injection guide](https://www.owasp.org/index.php/SQL_Injection). +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.
@@ -198,62 +210,14 @@ prisma.$queryRawUnsafe( > **Note**: Prisma sends JavaScript integers to PostgreSQL as `INT8`. This might conflict with your user-defined functions that accept only `INT4` as input. If you use a parameterized `$queryRawUnsafe` query in conjunction with a PostgreSQL database, update the input types to `INT8`, or cast your query parameters to `INT4`. +For more details on using parameterized queries, see the [parameterized queries](#parameterized-queries) section below. + #### Signature ```ts no-lines $queryRawUnsafe(query: string, ...values: any[]): PrismaPromise; ``` -#### Parameterized queries - -As an alternative to tagged templates, `$queryRawUnsafe` supports standard parameterized queries where each variable is represented by a symbol (`?` for mySQL, `$1`, `$2`, and so on for PostgreSQL). The following example uses a MySQL query: - -```ts -const userName = 'Sarah' -const email = 'sarah@prisma.io' -const result = await prisma.$queryRawUnsafe( - 'SELECT * FROM User WHERE (name = ? OR email = ?)', - userName, - email -) -``` - -> **Note**: MySQL variables are represented by `?` - -The following example uses a PostgreSQL query: - -```ts -const userName = 'Sarah' -const email = 'sarah@prisma.io' -const result = await prisma.$queryRawUnsafe( - 'SELECT * FROM User WHERE (name = $1 OR email = $2)', - userName, - email -) -``` - -> **Note**: PostgreSQL variables are represented by `$1` and `$2` - -As with tagged templates, Prisma Client escapes all variables. - -> **Note**: You cannot pass a table or column name as a variable into a parameterized query. For example, you cannot `SELECT ?` and pass in `*` or `id, name` based on some condition. - -##### Parameterized PostgreSQL `ILIKE` query - -When you use `ILIKE`, the `%` wildcard character(s) should be included in the variable itself, not the query (`string`): - -```ts -const userName = 'Sarah' -const emailFragment = 'prisma.io' -const result = await prisma.$queryRawUnsafe( - 'SELECT * FROM "User" WHERE (name = $1 OR email ILIKE $2)', - userName, - `%${emailFragment}` -) -``` - -> **Note**: Using `%$2` as an argument would not work - ### $executeRaw `$executeRaw` returns the _number of rows affected by a database operation_, such as `UPDATE` or `DELETE`. This function does **not** return database records. The following query updates records in the database and returns a count of the number of records that were updated: @@ -263,7 +227,7 @@ const result: number = await prisma.$executeRaw`UPDATE User SET active = true WHERE emailValidated = true` ``` -The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma creates prepared statements that are safe from SQL injections: +The method is implemented as a [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates), which allows you to pass a template literal where you can easily insert your [variables](#using-variables). In turn, Prisma Client creates prepared statements that are safe from SQL injections: ```ts const emailValidated = true @@ -273,6 +237,14 @@ const result: number = await prisma.$executeRaw`UPDATE User SET active = ${active} WHERE emailValidated = ${emailValidated};` ``` + + +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 prefered 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 + Be aware that: - `$executeRaw` does not support multiple queries in a single string (for example, `ALTER TABLE` and `CREATE TABLE` together). @@ -323,13 +295,11 @@ $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. -> **Note**: `$executeRawUnsafe` can only run **one** query at a time. You cannot append a second query - for example, adding `DROP bobby_tables` to the end of an `ALTER`. - 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.

-We strongly advise that you use the `$executeRaw` query instead. For more information on SQL injection attacks, see the [OWASP SQL Injection guide](https://www.owasp.org/index.php/SQL_Injection). +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.
@@ -354,6 +324,8 @@ const result = prisma.$executeRawUnsafe( ) ``` +For more details on using parameterized queries, see the [parameterized queries](#parameterized-queries) section below. + #### Signature ```ts no-lines @@ -422,7 +394,7 @@ Note that the exact name for each database type will vary between databases – ### PostgreSQL typecasting fixes -Prisma resolves a number of issues with typecasting in PostgreSQL. +Prisma ORM resolves a number of issues with typecasting in PostgreSQL. @@ -445,7 +417,7 @@ A consequence of this fix is that some subtle implicit casts are now handled mor await prisma.$queryRaw`SELECT LENGTH(${42});` ``` -Before version 4.0.0, Prisma silently coerces `42` to `text`. From version 4.0.0, the query returns an error: +Before version 4.0.0, Prisma ORM silently coerces `42` to `text`. From version 4.0.0, the query returns an error: ```terminal wrap // ERROR: function length(integer) does not exist @@ -524,7 +496,7 @@ await prisma.$executeRawUnsafe('ALTER USER prisma WITH PASSWORD "$1"', password} ### Unsupported types -[`Unsupported` types](/orm/reference/prisma-schema-reference#unsupported) need to be cast to Prisma supported types before using them in `$queryRaw` or `$queryRawUnsafe`. For example, take the following model, which has a `location` field with an `Unsupported` type: +[`Unsupported` types](/orm/reference/prisma-schema-reference#unsupported) need to be cast to Prisma Client supported types before using them in `$queryRaw` or `$queryRawUnsafe`. For example, take the following model, which has a `location` field with an `Unsupported` type: ```tsx model Country { @@ -538,7 +510,7 @@ The following query on the unsupported field will **not** work: await prisma.$queryRaw`SELECT location FROM Country;` ``` -Instead, cast `Unsupported` fields to any supported Prisma type, **if your `Unsupported` column supports the cast**. +Instead, cast `Unsupported` fields to any supported Prisma Client type, **if your `Unsupported` column supports the cast**. The most common type you may want to cast your `Unsupported` column to is `String`. For example, on PostgreSQL, this would map to the `text` type: @@ -546,26 +518,188 @@ The most common type you may want to cast your `Unsupported` column to is `Strin await prisma.$queryRaw`SELECT location::text FROM Country;` ``` -The database will thus provide a `String` representation of your data which Prisma supports. +The database will thus provide a `String` representation of your data which Prisma Client supports. -For details of supported Prisma types, see the [Prisma data connector](/orm/overview) for the relevant database. +For details of supported Prisma types, see the [Prisma connector overview](/orm/overview/databases) for the relevant database. -### SQL injection +## SQL injection prevention -Prisma Client mitigates the risk of SQL injection in the following ways: +The ideal way to avoid SQL injection in Prisma Client is to use the ORM models to perform queries wherever possible. -- Prisma Client escapes all variables when you use tagged templates and sends all queries as prepared statements. +Where this is not possible and raw queries are required, Prisma Client provides various raw methods, but it is important to use these methods safely. - ```ts - $queryRaw`...` // Tagged template - $executeRaw`...` // Tagged template - ``` +This section will provide various examples of using these methods safely and unsafely. You can test these examples in the [Prisma Playground](https://playground.prisma.io/examples). -- `$executeRaw` can only run **one** query at a time. You cannot append a second query - for example, adding `DROP bobby_tables` to the end of an `ALTER`. +### In $queryRaw and $executeRaw -If you cannot use tagged templates, you can instead use [`$queryRawUnsafe`](/orm/prisma-client/queries/raw-database-access/raw-queries#queryrawunsafe) or [`$executeRawUnsafe`](/orm/prisma-client/queries/raw-database-access/raw-queries#executerawunsafe) but **be aware that your code may be vulnerable to SQL injection**. +#### Simple, safe use of $queryRaw and $executeRaw -#### ⚠️ String concatenation +These methods can mitigate the risk of SQL injection by escaping all variables when you use tagged templates and sends all queries as prepared statements. + +```ts +$queryRaw`...` // Tagged template +$executeRaw`...` // Tagged template +``` + +The following example is safe ✅ from SQL Injection: + +```ts +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const result = + await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${inputString}` + +console.log(result) +``` + +#### Unsafe use of $queryRaw and $executeRaw + +However, it is also possible to use these methods in unsafe ways. + +One way is by artificially generating a tagged template that unsafely concatenates user input. + +The following example is vulnerable ❌ to SQL Injection: + +```ts +// Unsafely generate query text +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` // SQL Injection +const query = `SELECT id, name FROM "User" WHERE name = ${inputString}` + +// Version for Typescript +const stringsArray: any = [...[query]] + +// Version for Javascript +const stringsArray = [...[query]] + +// Use the `raw` property to impersonate a tagged template +stringsArray.raw = [query] + +// Use queryRaw +const result = await prisma.$queryRaw(stringsArray) +console.log(result) +``` + +Another way to make these methods vulnerable is misuse of the `Prisma.raw` function. + +The following examples are all vulnerable ❌ to SQL Injection: + +```ts +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const result = + await prisma.$queryRaw`SELECT id, name FROM "User" WHERE name = ${Prisma.raw( + inputString + )}` +console.log(result) +``` + +```ts +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const result = await prisma.$queryRaw( + Prisma.raw(`SELECT id, name FROM "User" WHERE name = ${inputString}`) +) +console.log(result) +``` + +```ts +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +const query = Prisma.raw( + `SELECT id, name FROM "User" WHERE name = ${inputString}` +) +const result = await prisma.$queryRaw(query) +console.log(result) +``` + +#### Safely using $queryRaw and $executeRaw in more complex scenarios + +##### Building raw queries separate to query execution + +If you want to build your raw queries elsewhere or separate to your parameters you will need to use one of the following methods. + +In this example, the `sql` helper method is used to build the query text by safely including the variable. It is safe ✅ from SQL Injection: + +```ts +// inputString can be untrusted input +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` + +// Safe if the text query below is completely trusted content +const query = Prisma.sql`SELECT id, name FROM "User" WHERE name = ${inputString}` + +const result = await prisma.$queryRaw(query) +console.log(result) +``` + +In this example which is safe ✅ from SQL Injection, the `sql` helper method is used to build the query text including a parameter marker for the input value. Each variable is represented by a marker symbol (`?` for mySQL, `$1`, `$2`, and so on for PostgreSQL). Note that the examples just show PostgreSQL queries. + +```ts +// Version for Typescript +const query: any + +// Version for Javascript +const query + +// Safe if the text query below is completely trusted content +query = Prisma.sql`SELECT id, name FROM "User" WHERE name = $1` + +// inputString can be untrusted input +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +query.values = [inputString] + +const result = await prisma.$queryRaw(query) +console.log(result) +``` + +> **Note**: PostgreSQL variables are represented by `$1`, etc + +##### Building raw queries elsewhere or in stages + +If you want to build your raw queries somewhere other than where the query is executed, the ideal way to do this is to create an `Sql` object from the segments of your query and pass it the parameter value. + +In the following example we have two variables to parameterize. The example is safe ✅ from SQL Injection as long as the query strings being passed to `Prisma.sql` only contain trusted content: + +```ts +// Example is safe if the text query below is completely trusted content +const query1 = `SELECT id, name FROM "User" WHERE name = ` // The first parameter would be inserted after this string +const query2 = ` OR name = ` // The second parameter would be inserted after this string + +const inputString1 = "Fred" +const inputString2 = `'Sarah' UNION SELECT id, title FROM "Post"` + +const query = Prisma.sql([query1, query2, ""], inputString1, inputString2) +const result = await prisma.$queryRaw(query); +console.log(result); +``` + +> Note: Notice that the string array being passed as the first parameter `Prisma.sql` needs to have an empty string at the end as the `sql` function expects one more query segment than the number of parameters. + +If you want to build your raw queries into one large string, this is still possible but requires some care as it is uses the potentially dangerous `Prisma.raw` method. You also need to build your query using the correct parameter markers for your database as Prisma won't be able to provide markers for the relevant database as it usually is. + +The following example is safe ✅ from SQL Injection as long as the query strings being passed to `Prisma.raw` only contain trusted content: + +```ts +// Version for Typescript +const query: any + +// Version for Javascript +const query + +// Example is safe if the text query below is completely trusted content +const query1 = `SELECT id, name FROM "User" ` +const query2 = `WHERE name = $1 ` + +query = Prisma.raw(`${query1}${query2}`) + +// inputString can be untrusted input +const inputString = `'Sarah' UNION SELECT id, title FROM "Post"` +query.values = [inputString] + +const result = await prisma.$queryRaw(query) +console.log(result) +``` + +### In $queryRawUnsafe and $executeRawUnsafe + +#### Using $queryRawUnsafe and $executeRawUnsafe unsafely + +If you cannot use tagged templates, you can instead use [`$queryRawUnsafe`](/orm/prisma-client/queries/raw-database-access/raw-queries#queryrawunsafe) or [`$executeRawUnsafe`](/orm/prisma-client/queries/raw-database-access/raw-queries#executerawunsafe) but **be aware that your these functions make it much more likely that your code will be vulnerable to SQL injection**. The following example concatenates `query` and `inputString`. Prisma Client ❌ **cannot** escape `inputString` in this example, which makes it vulnerable to SQL injection: @@ -577,6 +711,44 @@ const result = await prisma.$queryRawUnsafe(query) console.log(result) ``` +#### Parameterized queries + +As an alternative to tagged templates, `$queryRawUnsafe` supports standard parameterized queries where each variable is represented by a symbol (`?` for mySQL, `$1`, `$2`, and so on for PostgreSQL). Note that the examples just show PostgreSQL queries. + +The following example is safe ✅ from SQL Injection: + +```ts +const userName = 'Sarah' +const email = 'sarah@prisma.io' +const result = await prisma.$queryRawUnsafe( + 'SELECT * FROM User WHERE (name = $1 OR email = $2)', + userName, + email +) +``` + +> **Note**: PostgreSQL variables are represented by `$1` and `$2` + +As with tagged templates, Prisma Client escapes all variables when they are provided in this way. + +> **Note**: You cannot pass a table or column name as a variable into a parameterized query. For example, you cannot `SELECT ?` and pass in `*` or `id, name` based on some condition. + +##### Parameterized PostgreSQL `ILIKE` query + +When you use `ILIKE`, the `%` wildcard character(s) should be included in the variable itself, not the query (`string`). This example is safe ✅ from SQL Injection. + +```ts +const userName = 'Sarah' +const emailFragment = 'prisma.io' +const result = await prisma.$queryRawUnsafe( + 'SELECT * FROM "User" WHERE (name = $1 OR email ILIKE $2)', + userName, + `%${emailFragment}` +) +``` + +> **Note**: Using `%$2` as an argument would not work + ## Raw queries with MongoDB For MongoDB in versions `3.9.0` and later, Prisma Client exposes three methods that allow you to send raw queries. You can use: diff --git a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/100-custom-and-type-safe-queries.mdx b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/100-custom-and-type-safe-queries.mdx index eeba38fa7a..fc85d59890 100644 --- a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/100-custom-and-type-safe-queries.mdx +++ b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/100-custom-and-type-safe-queries.mdx @@ -12,7 +12,7 @@ The example will be using [PostGIS](https://postgis.net/) and PostgreSQL, but is ## What is SafeQL? -[SafeQL](https://safeql.dev/) allows for advanced linting and type safety within raw SQL queries. After setup, SafeQL works with Prisma `$queryRaw` and `$executeRaw` to provide type safety when raw queries are required. +[SafeQL](https://safeql.dev/) allows for advanced linting and type safety within raw SQL queries. After setup, SafeQL works with Prisma Client `$queryRaw` and `$executeRaw` to provide type safety when raw queries are required. SafeQL runs as an [ESLint](https://eslint.org/) plugin and is configured using ESLint rules. This guide doesn't cover setting up ESLint and we will assume that you already having it running in your project. @@ -21,18 +21,18 @@ SafeQL runs as an [ESLint](https://eslint.org/) plugin and is configured using E To follow along, you will be expected to have: - A [PostgreSQL](https://www.postgresql.org/) database with PostGIS installed -- Prisma set up in your project +- Prisma ORM set up in your project - ESLint set up in your project -## Geographic data support in Prisma +## Geographic data support in Prisma ORM -At the time of writing, Prisma does not support working with geographic data, specifically using [PostGIS](https://github.com/prisma/prisma/issues/2789). +At the time of writing, Prisma ORM does not support working with geographic data, specifically using [PostGIS](https://github.com/prisma/prisma/issues/2789). A model that has geographic data columns will be stored using the [`Unsupported`](/orm/reference/prisma-schema-reference#unsupported) data type. Fields with `Unsupported` types are present in the generated Prisma Client and will be typed as `any`. A model with a required `Unsupported` type does not expose write operations such as `create`, and `update`. -Prisma supports write operations on models with a required `Unsupported` field using `$queryRaw` and `$executeRaw`. You can use Prisma Client extensions and SafeQL to improve the type-safety when working with geographical data in raw queries. +Prisma Client supports write operations on models with a required `Unsupported` field using `$queryRaw` and `$executeRaw`. You can use Prisma Client extensions and SafeQL to improve the type-safety when working with geographical data in raw queries. -## 1. Set up Prisma for use with PostGIS +## 1. Set up Prisma ORM for use with PostGIS If you haven't already, enable the `postgresqlExtensions` Preview feature and add the `postgis` PostgreSQL extension in your Prisma schema: @@ -99,7 +99,7 @@ model PointOfInterest { } ``` -You'll notice that the `location` field uses an [`Unsupported`](/orm/reference/prisma-schema-reference#unsupported) type. This means that we lose a lot of the benefits of Prisma when working with `PointOfInterest`. We'll be using [SafeQL](https://safeql.dev/) to fix this. +You'll notice that the `location` field uses an [`Unsupported`](/orm/reference/prisma-schema-reference#unsupported) type. This means that we lose a lot of the benefits of Prisma ORM when working with `PointOfInterest`. We'll be using [SafeQL](https://safeql.dev/) to fix this. Like before, create and execute a migration using the `prisma migrate dev` command to create the `PointOfInterest` table in your database: @@ -122,7 +122,7 @@ CREATE TABLE "PointOfInterest" ( ## 3. Integrate SafeQL -SafeQL is easily integrated with Prisma in order to lint `$queryRaw` and `$executeRaw` Prisma operations. You can reference [SafeQL's integration guide](https://safeql.dev/compatibility/prisma.html) or follow the steps below. +SafeQL is easily integrated with Prisma ORM in order to lint `$queryRaw` and `$executeRaw` Prisma operations. You can reference [SafeQL's integration guide](https://safeql.dev/compatibility/prisma.html) or follow the steps below. ### 3.1. Install the @ts-safeql/eslint-plugin npm package @@ -178,7 +178,7 @@ module.exports = { Finally, set up a `connectionUrl` for SafeQL so that it can introspect your database and retrieve the table and column names you use in your schema. SafeQL then uses this information for linting and highlighting problems in your raw SQL statements. -Our example relies on the [`dotenv`](https://github.com/motdotla/dotenv) package to get the same connection string that is used by Prisma. We recommend this in order to keep your database URL out of version control. +Our example relies on the [`dotenv`](https://github.com/motdotla/dotenv) package to get the same connection string that is used by Prisma ORM. We recommend this in order to keep your database URL out of version control. If you haven't installed `dotenv` yet, you can install it as follows: @@ -364,6 +364,6 @@ error Invalid Query: function st_distancesphere(geography, geometry) does not e ## Conclusion -While you may sometimes need to drop down to raw SQL when using Prisma, you can use various techniques to make the experience of writing raw SQL queries with Prisma better. +While you may sometimes need to drop down to raw SQL when using Prisma ORM, you can use various techniques to make the experience of writing raw SQL queries with Prisma ORM better. In this article, you have used SafeQL and Prisma Client extensions to create custom, type-safe Prisma Client queries to abstract PostGIS operations which are currently not natively supported in Prisma ORM. diff --git a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/index.mdx b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/index.mdx index ca494a4828..eaa0881cf3 100644 --- a/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/index.mdx +++ b/content/200-orm/200-prisma-client/100-queries/090-raw-database-access/index.mdx @@ -4,6 +4,17 @@ metaTitle: 'Raw database access' metaDescription: 'Raw database access with Prisma Client.' --- +While Prisma ORM aims to make all your database queries intuitive, type-safe, and convenient, there may be situations where you need to drop down to raw queries. + +This may happen for several reasons, e.g., because you need to optimize the performance of a specific query or because your data requirements can't be expressed by Prisma Client's query API. + +In that case, you can use one of Prisma Client's escape hatches, such as `$queryRaw` or `$executeRaw`, to send raw queries to the database. + +When using relational databases, you can use **community tools** that can still vastly improve the developer experience writing raw SQL, e.g., by enabling type safety or providing auto-completion for your SQL queries: + +- [`prisma-extension-kysely`](https://github.com/eoin-obrien/prisma-extension-kysely): A Client extension that uses the [Kysely](https://kysely.dev/) SQL query builder API to compose SQL queries in TypeScript, with auto-completion and type safety, and submits them through Prisma Client's connection pool. +- [SafeQL](https://safeql.dev/compatibility/prisma.html): An ESLint plugin enabling syntax highlighting and type safety for SQL strings inside Prisma ORM's raw SQL escape hatches. For a tutorial on using SafeQL, visit this [page](/orm/prisma-client/queries/raw-database-access/custom-and-type-safe-queries). + ## In this section diff --git a/content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx b/content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx index b5063dfdf5..90d8835feb 100644 --- a/content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx +++ b/content/200-orm/200-prisma-client/100-queries/100-query-optimization-performance.mdx @@ -21,7 +21,7 @@ Alternatively, if you are only interested in the time taken to run a query, you The n+1 problem occurs when you loop through the results of a query and perform one additional query **per result**, resulting in `n` number of queries plus the original (n+1). This is a common problem with ORMs, particularly in combination with GraphQL, because it is not always immediately obvious that your code is generating inefficient queries. -### Solving n+1 in GraphQL with findUnique and Prisma's dataloader +### Solving n+1 in GraphQL with findUnique and Prisma Client's dataloader
@@ -150,7 +150,7 @@ const User = objectType({ -Instead, use `findUnique` in combination with [the fluent API](/orm/prisma-client/queries/relation-queries#fluent-api) (`.posts()`) as shown to return a user's posts. Even though the resolver is called once per user, the Prisma dataloader **✔ batches the `findUnique` queries**. +Instead, use `findUnique` in combination with [the fluent API](/orm/prisma-client/queries/relation-queries#fluent-api) (`.posts()`) as shown to return a user's posts. Even though the resolver is called once per user, the Prisma dataloader in Prisma Client **✔ batches the `findUnique` queries**. @@ -209,13 +209,13 @@ const User = objectType({ -If the `posts` resolver is invoked once per user, Prisma's dataloader groups `findUnique` queries with the same parameters and selection set. Each group is optimized into a single `findMany`. +If the `posts` resolver is invoked once per user, the dataloader in Prisma Client groups `findUnique` queries with the same parameters and selection set. Each group is optimized into a single `findMany`. #### Do I have to use the fluent API to enable batching of queries? It may seem counterintitive to use a `prisma.user.findUnique(...).posts()` query to return posts instead of `prisma.posts.findMany()` - particularly as the former results in two queries rather than one. -The **only** reason you need to use the fluent API (`user.findUnique(...).posts()`) to return posts is that Prisma's dataloader batches `findUnique` queries and does not currently [batch `findMany` queries](https://github.com/prisma/prisma/issues/1477). +The **only** reason you need to use the fluent API (`user.findUnique(...).posts()`) to return posts is that the dataloader in Prisma Client batches `findUnique` queries and does not currently [batch `findMany` queries](https://github.com/prisma/prisma/issues/1477). When the dataloader batches `findMany` queries, you no longer need to use `findUnique` with the fluent API in this way. 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 0019e4779b..ff7beb91be 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 @@ -132,7 +132,7 @@ The `bitDepth` field has no content because you have only just added this field, ** Earlier versions ** -Before version 4.0.0, Prisma threw a P2032 error as follows: +Before version 4.0.0, Prisma ORM threw a P2032 error as follows: ``` Error converting field "bitDepth" of expected non-nullable @@ -717,7 +717,7 @@ Be careful when you carry out any of the following operations on a record with a If your schema has a composite type with a `@@unique` constraint, MongoDB prevents you from storing the same value for the constrained value in two or more of the records that contain this composite type. However, MongoDB does does not prevent you from storing multiple copies of the same field value in a single record. -Note that you can [use Prisma relations to work around this issue](#use-prisma-relations-to-enforce-unique-values-in-a-record). +Note that you can [use Prisma ORM relations to work around this issue](#use-prisma-orm-relations-to-enforce-unique-values-in-a-record). For example, in the following schema, `MailBox` has a composite type, `addresses`, which has a `@@unique` constraint on the `email` field. @@ -758,9 +758,9 @@ await prisma.MailBox.createMany({ Note: MongoDB throws an error if you try to store the same value in two separate records. In our example above, if you try to store the email address `alice@prisma.io` for the user Alice and for the user Bob, MongoDB does not store the data and throws an error. -### Use Prisma relations to enforce unique values in a record +### Use Prisma ORM relations to enforce unique values in a record -In the example above, MongoDB did not enforce the unique constraint on a nested address name. However, you can model your data differently to enforce unique values in a record. To do so, use Prisma [relations](/orm/prisma-schema/data-model/relations) to turn the composite type into a collection. Set a relationship to this collection and place a unique constraint on the field that you want to be unique. +In the example above, MongoDB did not enforce the unique constraint on a nested address name. However, you can model your data differently to enforce unique values in a record. To do so, use Prisma ORM [relations](/orm/prisma-schema/data-model/relations) to turn the composite type into a collection. Set a relationship to this collection and place a unique constraint on the field that you want to be unique. In the following example, MongoDB enforces unique values in a record. There is a relation between `Mailbox` and the `Address` model. Also, the `name` field in the `Address` model has a unique constraint. 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 cd0a91033b..a7ac15bbd6 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 @@ -14,7 +14,7 @@ Prisma Client differentiates between `null` and `undefined`: -This is particularly important to account for in [a **Prisma with GraphQL context**, where `null` and `undefined` are interchangeable](#null-and-undefined-in-a-graphql-resolver). +This is particularly important to account for in [a **Prisma ORM with GraphQL context**, where `null` and `undefined` are interchangeable](#null-and-undefined-in-a-graphql-resolver). @@ -130,7 +130,7 @@ This query will select every row from the `User` table. -**Note**: Using `undefined` as the value of any key in a Prisma Client query's parameter object will cause Prisma to act as if that key was not provided at all. +**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. @@ -249,10 +249,10 @@ type Mutation { } ``` -However, if you pass `null` values for `authorEmail` or `authorName` on to Prisma, the following will happen: +However, if you pass `null` values for `authorEmail` or `authorName` on to Prisma Client, the following will happen: - If `args.authorEmail` is `null`, the query will **fail**. `email` does not accept `null`. -- If `args.authorName` is `null`, Prisma changes the value of `name` to `null`. This is probably not how you want an update to work. +- If `args.authorName` is `null`, Prisma Client changes the value of `name` to `null`. This is probably not how you want an update to work. ```ts updateUser: (parent, args, ctx: Context) => { @@ -282,7 +282,7 @@ updateUser: (parent, args, ctx: Context) => { ## The effect of null and undefined on conditionals -There are some caveats to filtering with conditionals which might produce unexpected results. When filtering with conditionals you might expect one result but receive another given how Prisma treats nullable values. +There are some caveats to filtering with conditionals which might produce unexpected results. When filtering with conditionals you might expect one result but receive another given how Prisma Client treats nullable values. The following table provides a high-level overview of how the different operators handle 0, 1 and `n` filters. 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 360138c09c..e615b2d492 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 @@ -7,7 +7,7 @@ tocDepth: 3 -Use the [`Json`](/orm/reference/prisma-schema-reference#json) Prisma field type to read, write, and perform basic filtering on JSON types in the underlying database. In the following example, the `User` model has an optional `Json` field named `extendedPetsData`: +Use the [`Json`](/orm/reference/prisma-schema-reference#json) Prisma ORM field type to read, write, and perform basic filtering on JSON types in the underlying database. In the following example, the `User` model has an optional `Json` field named `extendedPetsData`: ```prisma highlight=6;normal model User { @@ -112,7 +112,7 @@ See also: [Advanced example: Update a nested JSON key value](#advanced-example-u From v2.23.0, you can filter rows by the data inside a `Json` type. We call this **advanced `Json` filtering**. -The availability of advanced `Json` filtering depends on your Prisma version: +The availability of advanced `Json` filtering depends on your Prisma ORM version: - V4.0.0 or later: advanced `Json` filtering is [generally available](/orm/more/releases#generally-available-ga). - 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). @@ -547,18 +547,20 @@ const checkJson = await prisma.user.findMany({ - If you are using PostgreSQL, you must pass in an array of objects to match, even if that array only contains one object: ```json5 - [{ status: 'expired', insuranceID: 92 }] // PostgreSQL + [{ status: 'expired', insuranceID: 92 }] + // PostgreSQL ``` If you are using MySQL, you must pass in a single object to match: ```json5 - { status: 'expired', insuranceID: 92 } // MySQL + { status: 'expired', insuranceID: 92 } + // MySQL ``` - If your filter array contains multiple objects, PostgreSQL will only return results if _all_ objects are present - not if at least one object is present. -- You must set `array_contains` to a JSON object, not a string. If you use a string, Prisma escapes the quotation marks and the query will not return results. For example: +- You must set `array_contains` to a JSON object, not a string. If you use a string, Prisma Client escapes the quotation marks and the query will not return results. For example: ```ts array_contains: '[{"status": "expired", "insuranceID": 92}]' @@ -957,6 +959,46 @@ These _null enums_ do not apply to MongoDB because MongoDB does not differentiat +## Typed Json + +By default, `Json` fields are not typed in Prisma models. To accomplish strong typing inside of these fields, you will need to use an external package like [prisma-json-types-generator](https://www.npmjs.com/package/prisma-json-types-generator) to accomplish this. + +### Using prisma-json-types-generator + +First, install and configure `prisma-json-types-generator` [according to the package's instructions](https://www.npmjs.com/package/prisma-json-types-generator#using-it). + +Then, assuming you have a model like the following: + +```prisma no-copy +model Log { + id Int @id + meta Json +} +``` + +You can update it and type it by using [abstract syntax tree comments](/orm/prisma-schema/overview#comments) + +```prisma highlight=4;normal file=schema.prisma +model Log { + id Int @id + + /// [LogMetaType] + meta Json +} +``` + +Then, make sure you define the above type in a type declaration file included in your `tsconfig.json` + +```ts file=types.ts +declare global { + namespace PrismaJson { + type LogMetaType = { timestamp: number; host: string } + } +} +``` + +Now, when working with `Log.meta` it will be strongly typed! + ## Json FAQs ### Can you select a subset of JSON key/values to return? diff --git a/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx b/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx index 8d5d232b72..72455c4432 100644 --- a/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx +++ b/content/200-orm/200-prisma-client/200-special-fields-and-types/index.mdx @@ -47,7 +47,7 @@ const newTypes = await prisma.sample.create({ ### Serializing BigInt -Prisma returns records as plain JavaScript objects. If you attempt to use `JSON.stringify` on an object that includes a `BigInt` field, you will see the following error: +Prisma Client returns records as plain JavaScript objects. If you attempt to use `JSON.stringify` on an object that includes a `BigInt` field, you will see the following error: ``` Do not know how to serialize a BigInt diff --git a/content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions.mdx b/content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions.mdx index cd27e58d20..5efcefbe4f 100644 --- a/content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions.mdx +++ b/content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions.mdx @@ -40,7 +40,7 @@ When you call a method in an extension, use the constant name from your `$extend ## Create a shareable extension -When you want to create extensions other users can use, and that are not tailored just for your schema, Prisma provides utilities to allow you to create shareable extensions. +When you want to create extensions other users can use, and that are not tailored just for your schema, Prisma ORM provides utilities to allow you to create shareable extensions. To create a shareable extension: diff --git a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/100-soft-delete-middleware.mdx b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/100-soft-delete-middleware.mdx index 4bf804a10e..1eaba0e919 100644 --- a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/100-soft-delete-middleware.mdx +++ b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/100-soft-delete-middleware.mdx @@ -277,12 +277,12 @@ In step 2, we implemented middleware that prevents `Post` records from being del In this option: -- Prisma middleware is responsible for preventing records from being deleted +- Prisma Client middleware is responsible for preventing records from being deleted - Your own application code (which could be a GraphQL API, a REST API, a module) is responsible for filtering out deleted posts where necessary (`{ where: { deleted: false } }`) when reading and updating data - for example, the `getPost` GraphQL resolver never returns a deleted post ✔ Pros of this approach to soft delete include: -- No change to Prisma's create/update queries - you can easily request deleted records if you need them +- No change to Prisma Client's create/update queries - you can easily request deleted records if you need them - Modifying queries in middleware can have some unintended consequences, such as changing query return types (see option 2) ✘ Cons of this approach to soft delete include: @@ -292,7 +292,7 @@ In this option: ### Option 2: Use middleware to determine the behavior of read/update queries for deleted records -Option two uses Prisma middleware to prevent soft deleted records from being returned. The following table describes how the middleware affects each query: +Option two uses Prisma Client middleware to prevent soft deleted records from being returned. The following table describes how the middleware affects each query: | **Query** | **Middleware logic** | **Changes to return type** | | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------- | --- | diff --git a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/200-logging-middleware.mdx b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/200-logging-middleware.mdx index fbf2da4f85..b13eda09f9 100644 --- a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/200-logging-middleware.mdx +++ b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/200-logging-middleware.mdx @@ -6,7 +6,7 @@ metaDescription: 'How to use middleware to log the time taken to perform any que -The following example logs the time taken for a Prisma Query to run: +The following example logs the time taken for a Prisma Client query to run: ```ts const prisma = new PrismaClient() diff --git a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/index.mdx b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/index.mdx index d75f3f222c..2d87c9e730 100644 --- a/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/index.mdx +++ b/content/200-orm/200-prisma-client/300-client-extensions/500-middleware/index.mdx @@ -67,7 +67,7 @@ The following sample scenarios show how to use middleware in practice: ## Where to add middleware -Add Prisma middleware **outside the context of the request handler**, otherwise each request adds a new _instance_ of the middleware to the stack. The following example demonstrates where to add Prisma middleware in the context of an Express app: +Add Prisma Client middleware **outside the context of the request handler**, otherwise each request adds a new _instance_ of the middleware to the stack. The following example demonstrates where to add Prisma Client middleware in the context of an Express app: ```ts highlight=6-11;normal import express from 'express' 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 ee8db883ce..93364bee44 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 @@ -32,7 +32,7 @@ When you use a Prisma Client extension, you create an _extended client_. An exte You can associate a single extension, or multiple extensions, with an extended client. [Learn more about multiple extensions](#multiple-extensions). -You can [share your Prisma Client extensions](/orm/prisma-client/client-extensions/shared-extensions) with other Prisma users, and [import Prisma Client extensions developed by other users](/orm/prisma-client/client-extensions/shared-extensions#install-a-shared-packaged-extension) into your Prisma project. +You can [share your Prisma Client extensions](/orm/prisma-client/client-extensions/shared-extensions) with other Prisma ORM users, and [import Prisma Client extensions developed by other users](/orm/prisma-client/client-extensions/shared-extensions#install-a-shared-packaged-extension) into your Prisma ORM project. ### Extended clients @@ -40,7 +40,7 @@ Extended clients interact with each other, and with the standard client, as foll - Each extended client operates independently in an isolated instance. - Extended clients cannot conflict with each other, or with the standard client. -- All extended clients and the standard client communicate with the same [Prisma query engine](/orm/more/under-the-hood/engines). +- All extended clients and the standard client communicate with the same [Prisma ORM query engine](/orm/more/under-the-hood/engines). - All extended clients and the standard client share the same connection pool. > **Note**: The author of an extension can modify this behavior since they're able to run arbitrary code as part of an extension. For example, an extension might actually create an entirely new `PrismaClient` instance (including its own query engine and connection pool). Be sure to check the documentation of the extension you're using to learn about any specific behavior it might implement. diff --git a/content/200-orm/200-prisma-client/400-type-safety/050-prisma-validator.mdx b/content/200-orm/200-prisma-client/400-type-safety/050-prisma-validator.mdx index c88245b2ed..7877c696e6 100644 --- a/content/200-orm/200-prisma-client/400-type-safety/050-prisma-validator.mdx +++ b/content/200-orm/200-prisma-client/400-type-safety/050-prisma-validator.mdx @@ -12,7 +12,7 @@ This page introduces the `Prisma.validator` and offers some motivations behind w -> **Note**: If you have a use case for `Prisma.validator`, be sure to check out this [blog post](https://www.prisma.io/blog/satisfies-operator-ur8ys8ccq7zb) about improving your Prisma workflows with the new TypeScript `satisfies` keyword. It's likely that you can solve your use case natively using `satisfies` instead of using `Prisma.validator`. +> **Note**: If you have a use case for `Prisma.validator`, be sure to check out this [blog post](https://www.prisma.io/blog/satisfies-operator-ur8ys8ccq7zb) about improving your Prisma Client workflows with the new TypeScript `satisfies` keyword. It's likely that you can solve your use case natively using `satisfies` instead of using `Prisma.validator`. ## Creating a typed query statement diff --git a/content/200-orm/200-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx b/content/200-orm/200-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx index 751a0ce83b..5867bca503 100644 --- a/content/200-orm/200-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx +++ b/content/200-orm/200-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx @@ -128,7 +128,7 @@ const usersWithPosts: UsersWithPosts = await getUsersWithPosts() ### Solution -With the `PromiseReturnType` that is exposed by the Prisma namespace, you can solve this more elegantly: +With the `PromiseReturnType` that is exposed by the `Prisma` namespace, you can solve this more elegantly: ```ts import { Prisma } from '@prisma/client' 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 e00397c0f8..3f4ba0df02 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 @@ -1,18 +1,18 @@ --- -title: How to use Prisma's type system -metaDescription: How to use Prisma's type system +title: How to use Prisma ORM's type system +metaDescription: How to use Prisma ORM's type system tocDepth: 3 --- -This guide introduces Prisma's type system and explains how to introspect existing native types in your database, and how to use types when you apply schema changes to your database with Prisma Migrate or `db push`. +This guide introduces Prisma ORM's type system and explains how to introspect existing native types in your database, and how to use types when you apply schema changes to your database with Prisma Migrate or `db push`. -## How does Prisma's type system work? +## How does Prisma ORM's type system work? -Prisma uses _types_ to define the kind of data that a field can hold. To make it easy to get started, Prisma provides a small number of core [scalar types](/orm/reference/prisma-schema-reference#model-field-scalar-types) that should cover most default use cases. For example, take the following blog post model: +Prisma ORM uses _types_ to define the kind of data that a field can hold. To make it easy to get started, Prisma ORM provides a small number of core [scalar types](/orm/reference/prisma-schema-reference#model-field-scalar-types) that should cover most default use cases. For example, take the following blog post model: ```prisma file=schema.prisma datasource db { @@ -35,17 +35,17 @@ In the blog post example above, we are using the PostgreSQL connector. This is s ### Default type mappings -To allow you to get started with our core scalar types, Prisma provides _default type mappings_ that map each scalar type to a default type in the underlying database. For example: +To allow you to get started with our core scalar types, Prisma ORM provides _default type mappings_ that map each scalar type to a default type in the underlying database. For example: -- by default Prisma's `String` type gets mapped to PostgreSQL's `text` type and MySQL's `varchar` type -- by default Prisma's `DateTime` type gets mapped to PostgreSQL's `timestamp(3)` type and SQL Server's `datetime2` type +- by default Prisma ORM's `String` type gets mapped to PostgreSQL's `text` type and MySQL's `varchar` type +- by default Prisma ORM's `DateTime` type gets mapped to PostgreSQL's `timestamp(3)` type and SQL Server's `datetime2` type -See Prisma's [database connector pages](/orm/overview) for the default type mappings for a given database. For example, [this table](/orm/overview/databases/postgresql#type-mapping-between-postgresql-and-prisma-schema) gives the default type mappings for PostgreSQL. -To see the default type mappings for all databases for a specific given Prisma type, see the [model field scalar types section](/orm/reference/prisma-schema-reference#model-field-scalar-types) of the Prisma schema reference. For example, [this table](/orm/reference/prisma-schema-reference#float) gives the default type mappings for the `Float` scalar type. +See Prisma ORM's [database connector pages](/orm/overview/databases) for the default type mappings for a given database. For example, [this table](/orm/overview/databases/postgresql#type-mapping-between-postgresql-and-prisma-schema) gives the default type mappings for PostgreSQL. +To see the default type mappings for all databases for a specific given Prisma ORM type, see the [model field scalar types section](/orm/reference/prisma-schema-reference#model-field-scalar-types) of the Prisma schema reference. For example, [this table](/orm/reference/prisma-schema-reference#float) gives the default type mappings for the `Float` scalar type. ### Native type mappings -Sometimes you may need to use a more specific database type that is not one of the default type mappings for your Prisma type. For this purpose, Prisma provides [native type attributes](/orm/prisma-schema/data-model/models#native-types-mapping) to refine the core scalar types. For example, in the `createdAt` field of your `Post` model above you may want to use a date-only column in your underlying PostgreSQL database, by using the `date` type instead of the default type mapping of `timestamp(3)`. To do this, add a `@db.Date` native type attribute to the `createdAt` field: +Sometimes you may need to use a more specific database type that is not one of the default type mappings for your Prisma ORM type. For this purpose, Prisma ORM provides [native type attributes](/orm/prisma-schema/data-model/models#native-types-mapping) to refine the core scalar types. For example, in the `createdAt` field of your `Post` model above you may want to use a date-only column in your underlying PostgreSQL database, by using the `date` type instead of the default type mapping of `timestamp(3)`. To do this, add a `@db.Date` native type attribute to the `createdAt` field: ```prisma file=schema.prisma model Post { @@ -55,11 +55,11 @@ model Post { } ``` -Native type mappings allow you to express all the types in your database. However, you do not need to use them if the Prisma defaults satisfy your needs. This leads to a shorter, more readable Prisma schema for common use cases. +Native type mappings allow you to express all the types in your database. However, you do not need to use them if the Prisma ORM defaults satisfy your needs. This leads to a shorter, more readable Prisma schema for common use cases. ## How to introspect database types -When you [introspect](/orm/prisma-schema/introspection) an existing database, Prisma will take the database type of each table column and represent it in your Prisma schema using the correct Prisma type for the corresponding model field. If the database type is not the default database type for that Prisma scalar type, Prisma will also add a native type attribute. +When you [introspect](/orm/prisma-schema/introspection) an existing database, Prisma ORM will take the database type of each table column and represent it in your Prisma schema using the correct Prisma ORM type for the corresponding model field. If the database type is not the default database type for that Prisma ORM scalar type, Prisma ORM will also add a native type attribute. As an example, take a `User` table in a PostgreSQL database, with: @@ -93,7 +93,7 @@ model User { } ``` -The `id`, `name` and `isActive` columns in the database are mapped respectively to the `Int`, `String` and `Boolean` Prisma types. The database types are the _default_ database types for these Prisma types, so Prisma does not add any native type attributes. +The `id`, `name` and `isActive` columns in the database are mapped respectively to the `Int`, `String` and `Boolean` Prisma ORM types. The database types are the _default_ database types for these Prisma ORM types, so Prisma ORM does not add any native type attributes. Now add a `createdAt` column to your database with a data type of `date` by running the following SQL command: @@ -108,7 +108,7 @@ Introspect your database again: npx prisma db pull ``` -Your Prisma schema now includes the new `createdAt` field with a Prisma type of `DateTime`. The `createdAt` field also has a `@db.Date` native type attribute, because PostgreSQL's `date` is not the default type for the `DateTime` type: +Your Prisma schema now includes the new `createdAt` field with a Prisma ORM type of `DateTime`. The `createdAt` field also has a `@db.Date` native type attribute, because PostgreSQL's `date` is not the default type for the `DateTime` type: ```prisma file=schema.prisma highlight=5;add model User { @@ -121,7 +121,7 @@ model User { ## How to use types when you apply schema changes to your database -When you apply schema changes to your database using Prisma Migrate or `db push`, Prisma will use both the Prisma scalar type of each field and any native attribute it has to determine the correct database type for the corresponding column in the database. +When you apply schema changes to your database using Prisma Migrate or `db push`, Prisma ORM will use both the Prisma ORM scalar type of each field and any native attribute it has to determine the correct database type for the corresponding column in the database. As an example, create a Prisma schema with the following `Post` model: @@ -136,10 +136,10 @@ model Post { This `Post` model has: -- an `id` field with a Prisma type of `Int` -- a `title` field with a Prisma type of `String` -- a `createdAt` field with a Prisma type of `DateTime` -- an `updatedAt` field with a Prisma type of `DateTime` and a `@db.Date` native type attribute +- an `id` field with a Prisma ORM type of `Int` +- a `title` field with a Prisma ORM type of `String` +- a `createdAt` field with a Prisma ORM type of `DateTime` +- an `updatedAt` field with a Prisma ORM type of `DateTime` and a `@db.Date` native type attribute Now apply these changes to an empty PostgreSQL database with the following command, run from the root directory of your project: @@ -156,9 +156,9 @@ You will see that the database has a newly created `Post` table, with: Notice that the `@db.Date` native type attribute modifies the database type of the `updatedAt` column to `date`, rather than the default of `timestamp(3)`. -## More on using Prisma's type system +## More on using Prisma ORM's type system -For further reference information on using Prisma's type system, see the following resources: +For further reference information on using Prisma ORM's type system, see the following resources: -- The [database connector](/orm/overview) page for each database provider has a type mapping section with a table of default type mappings between Prisma types and database types, and a table of database types with their corresponding native type attribute in Prisma. For example, the type mapping section for PostgreSQL is [here](/orm/overview/databases/postgresql#type-mapping-between-postgresql-and-prisma-schema). -- The [model field scalar types](/orm/reference/prisma-schema-reference#model-field-scalar-types) section of the Prisma schema reference has a subsection for each Prisma scalar type. This includes a table of default mappings for that Prisma type in each database, and a table for each database listing the corresponding database types and their native type attributes in Prisma. For example, the entry for the `String` Prisma type is [here](/orm/reference/prisma-schema-reference#string). +- The [database connector](/orm/overview) page for each database provider has a type mapping section with a table of default type mappings between Prisma ORM types and database types, and a table of database types with their corresponding native type attribute in Prisma ORM. For example, the type mapping section for PostgreSQL is [here](/orm/overview/databases/postgresql#type-mapping-between-postgresql-and-prisma-schema). +- The [model field scalar types](/orm/reference/prisma-schema-reference#model-field-scalar-types) section of the Prisma schema reference has a subsection for each Prisma ORM scalar type. This includes a table of default mappings for that Prisma ORM type in each database, and a table for each database listing the corresponding database types and their native type attributes in Prisma ORM. For example, the entry for the `String` Prisma ORM type is [here](/orm/reference/prisma-schema-reference#string). 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 ce9e159278..eafec8cac1 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 @@ -9,7 +9,7 @@ tocDepth: 3 The generated code for Prisma Client contains several helpful types and utilities that you can use to make your application more type-safe. This page describes patterns for leveraging them. -> **Note**: If you're interested in advanced type safety topics with Prisma, be sure to check out this [blog post](https://www.prisma.io/blog/satisfies-operator-ur8ys8ccq7zb) about improving your Prisma workflows with the new TypeScript `satisfies` keyword. +> **Note**: If you're interested in advanced type safety topics with Prisma ORM, be sure to check out this [blog post](https://www.prisma.io/blog/satisfies-operator-ur8ys8ccq7zb) about improving your Prisma Client workflows with the new TypeScript `satisfies` keyword. @@ -235,7 +235,7 @@ We recommend using the "safe" `Input` types whenever possible. -This feature is available from Prisma version 4.9.0 upwards. +This feature is available from Prisma ORM version 4.9.0 upwards. 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 23a3473d3c..f7d7350777 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 @@ -1,6 +1,6 @@ --- title: 'Unit testing' -metaTitle: 'Unit testing with Prisma' +metaTitle: 'Unit testing with Prisma ORM' metaDescription: 'Learn how to setup and run unit tests with Prisma Client' tocDepth: 3 --- @@ -13,7 +13,7 @@ Unit testing aims to isolate a small portion (unit) of code and test it for logi - Provides documentation for each module of code by way of indicating what certain code blocks should be doing. - A helpful gauge that a refactor has gone well. The tests should still pass after code has been refactored. -In the context of Prisma, this generally means testing a function which makes database calls using Prisma Client. +In the context of Prisma ORM, this generally means testing a function which makes database calls using Prisma Client. A single test should focus on how your function logic handles different inputs (such as a null value or an empty list). @@ -21,7 +21,7 @@ This means that you should aim to remove as many dependencies as possible, such -> **Note**: This [blog post](https://www.prisma.io/blog/testing-series-2-xPhjjmIEsM) provides a comprehensive guide to implementing unit testing in your Express project with Prisma. If you're looking to delve into this topic, be sure to give it a read! +> **Note**: This [blog post](https://www.prisma.io/blog/testing-series-2-xPhjjmIEsM) provides a comprehensive guide to implementing unit testing in your Express project with Prisma ORM. If you're looking to delve into this topic, be sure to give it a read! ## Prerequisites @@ -135,11 +135,11 @@ to your `tsconfig.json`. }) ``` -This will create a new context before each test is run via the `createMockContext` function. This (`mockCtx`) context will be used to make a mock call to Prisma and run a query to test. The `ctx` context will be used to run a scenario query that is tested against. +This will create a new context before each test is run via the `createMockContext` function. This (`mockCtx`) context will be used to make a mock call to Prisma Client and run a query to test. The `ctx` context will be used to run a scenario query that is tested against. ## Example unit tests -A real world use case for unit testing Prisma might be a signup form. Your user fills in a form which calls a function, which in turn uses Prisma to make a call to your database. +A real world use case for unit testing Prisma ORM might be a signup form. Your user fills in a form which calls a function, which in turn uses Prisma Client to make a call to your database. All of the examples that follow use the following schema model: diff --git a/content/200-orm/200-prisma-client/450-testing/index.mdx b/content/200-orm/200-prisma-client/450-testing/index.mdx index 9523cc79c8..4d6ecb1200 100644 --- a/content/200-orm/200-prisma-client/450-testing/index.mdx +++ b/content/200-orm/200-prisma-client/450-testing/index.mdx @@ -1,8 +1,8 @@ --- title: 'Testing' navTitle: Testing -metaTitle: 'Testing with Prisma' -metaDescription: 'How to implement unit and integration testing with Prisma' +metaTitle: 'Testing with Prisma ORM' +metaDescription: 'How to implement unit and integration testing with Prisma ORM' --- diff --git a/content/200-orm/200-prisma-client/500-deployment/001-deploy-prisma.mdx b/content/200-orm/200-prisma-client/500-deployment/001-deploy-prisma.mdx index b733f5c803..abb76a5663 100644 --- a/content/200-orm/200-prisma-client/500-deployment/001-deploy-prisma.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/001-deploy-prisma.mdx @@ -1,6 +1,6 @@ --- -title: 'Deploy Prisma' -metaTitle: 'Deploying Prisma-based projects' +title: 'Deploy Prisma ORM' +metaTitle: 'Deploying Prisma ORM-based projects' metaDescription: 'Learn more about the different deployment paradigms for Node.js applications and how they affect deploying an application using Prisma Client.' tocDepth: 2 --- diff --git a/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx b/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx index 4242c91b81..eceb1cf94a 100644 --- a/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/101-traditional/200-deploy-to-heroku.mdx @@ -1,12 +1,12 @@ --- title: 'Deploy to Heroku' metaTitle: 'Deploy a Prisma app to Heroku' -metaDescription: 'Learn how to deploy a Node.js server that uses Prisma to Heroku.' +metaDescription: 'Learn how to deploy a Node.js server that uses Prisma ORM to Heroku.' --- -In this guide, you will set up and deploy a Node.js server that uses Prisma with PostgreSQL to [Heroku](https://www.heroku.com). The application exposes a REST API and uses Prisma Client to handle fetching, creating, and deleting records from a database. +In this guide, you will set up and deploy a Node.js server that uses Prisma ORM with PostgreSQL to [Heroku](https://www.heroku.com). The application exposes a REST API and uses Prisma Client to handle fetching, creating, and deleting records from a database. Heroku is a cloud platform as a service (PaaS). In contrast to the popular serverless deployment model, with Heroku, your application is constantly running even if no requests are made to it. This has several benefits due to the connection limits of a PostgreSQL database. For more information, check out the [general deployment documentation](/orm/prisma-client/deployment/deploy-prisma) @@ -19,7 +19,7 @@ The application has the following components: ![architecture diagram](./images/heroku-architecture.png) -The focus of this guide is showing how to deploy projects using Prisma to Heroku. The starting point will be the [Prisma Heroku example](https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/heroku), which contains an Express.js server with a couple of preconfigured REST endpoints and a simple frontend. +The focus of this guide is showing how to deploy projects using Prisma ORM to Heroku. The starting point will be the [Prisma Heroku example](https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/heroku), which contains an Express.js server with a couple of preconfigured REST endpoints and a simple frontend. > **Note:** The various **checkpoints** throughout the guide allowing you to validate whether you performed the steps correctly. @@ -38,9 +38,9 @@ While the example uses REST, the same principles apply to a GraphQL server, with > **Note:** Heroku doesn't provide a free plan, so billing information is required. -## Prisma workflow +## Prisma ORM workflow -At the core of Prisma is the [Prisma schema](/orm/prisma-schema) – a declarative configuration where you define your data model and other Prisma-related configuration. The Prisma schema is also a single source of truth for both Prisma Client and Prisma Migrate. +At the core of Prisma ORM is the [Prisma schema](/orm/prisma-schema) – a declarative configuration where you define your data model and other Prisma ORM-related configuration. The Prisma schema is also a single source of truth for both Prisma Client and Prisma Migrate. In this guide, you will use [Prisma Migrate](/orm/prisma-migrate) to create the database schema. Prisma Migrate is based on the Prisma schema and works by generating `.sql` migration files that are executed against the database. @@ -188,7 +188,7 @@ Database has been created and is available Created postgresql-parallel-73780 as DATABASE_URL ``` -> **Note:** Heroku automatically sets the `DATABASE_URL` environment variable when the app is running on Heroku. Prisma uses this environment variable because it's declared in the _datasource_ block of the Prisma schema (`prisma/schema.prisma`) with `env("DATABASE_URL")`. +> **Note:** Heroku automatically sets the `DATABASE_URL` environment variable when the app is running on Heroku. Prisma ORM uses this environment variable because it's declared in the _datasource_ block of the Prisma schema (`prisma/schema.prisma`) with `env("DATABASE_URL")`. ## 6. Push to deploy @@ -273,7 +273,7 @@ const server = app.listen(PORT, () => { ## Summary -Congratulations! You have successfully deployed a Node.js app with Prisma to Heroku. +Congratulations! You have successfully deployed a Node.js app with Prisma ORM to Heroku. You can find the source code for the example in [this GitHub repository](https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/heroku). diff --git a/content/200-orm/200-prisma-client/500-deployment/101-traditional/250-deploy-to-koyeb.mdx b/content/200-orm/200-prisma-client/500-deployment/101-traditional/250-deploy-to-koyeb.mdx index 6205ffddfb..8a9153f6a6 100644 --- a/content/200-orm/200-prisma-client/500-deployment/101-traditional/250-deploy-to-koyeb.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/101-traditional/250-deploy-to-koyeb.mdx @@ -1,12 +1,12 @@ --- title: 'Deploy to Koyeb' -metaTitle: 'Deploy a Prisma app to Koyeb' -metaDescription: 'Learn how to deploy a Node.js server that uses Prisma to Koyeb Serverless Platform.' +metaTitle: 'Deploy a Prisma ORM app to Koyeb' +metaDescription: 'Learn how to deploy a Node.js server that uses Prisma ORM to Koyeb Serverless Platform.' --- -In this guide, you will set up and deploy a Node.js server that uses Prisma with PostgreSQL to [Koyeb](https://www.koyeb.com). The application exposes a REST API and uses Prisma Client to handle fetching, creating, and deleting records from a database. +In this guide, you will set up and deploy a Node.js server that uses Prisma ORM with PostgreSQL to [Koyeb](https://www.koyeb.com). The application exposes a REST API and uses Prisma Client to handle fetching, creating, and deleting records from a database. Koyeb is a developer-friendly serverless platform to deploy apps globally. The platform lets you seamlessly run Docker containers, web apps, and APIs with git-based deployment, TLS encryption, native autoscaling, a global edge network, and built-in service mesh & discovery. @@ -20,7 +20,7 @@ The application has the following components: ![architecture diagram](./images/koyeb-architecture.png) -The focus of this guide is showing how to deploy projects using Prisma to Koyeb. The starting point will be the [Prisma Koyeb example](https://github.com/koyeb/example-prisma), which contains an Express.js server with a couple of preconfigured REST endpoints and a simple frontend. +The focus of this guide is showing how to deploy projects using Prisma ORM to Koyeb. The starting point will be the [Prisma Koyeb example](https://github.com/koyeb/example-prisma), which contains an Express.js server with a couple of preconfigured REST endpoints and a simple frontend. > **Note:** The various **checkpoints** throughout the guide allow you to validate whether you performed the steps correctly. @@ -33,9 +33,9 @@ The focus of this guide is showing how to deploy projects using Prisma to Koyeb. - [Koyeb](https://koyeb.com) account. - Node.js installed. -## Prisma workflow +## Prisma ORM workflow -At the core of Prisma is the [Prisma schema](/orm/prisma-schema) – a declarative configuration where you define your data model and other Prisma-related configuration. The Prisma schema is also a single source of truth for both Prisma Client and Prisma Migrate. +At the core of Prisma ORM is the [Prisma schema](/orm/prisma-schema) – a declarative configuration where you define your data model and other Prisma ORM-related configuration. The Prisma schema is also a single source of truth for both Prisma Client and Prisma Migrate. In this guide, you will create the database schema with [Prisma Migrate](/orm/prisma-migrate) to create the database schema. Prisma Migrate is based on the Prisma schema and works by generating `.sql` migration files that are executed against the database. @@ -195,7 +195,7 @@ In this guide, we kept pre-set values for the region, instance size, and horizon ## Summary -Congratulations! You have successfully deployed a Node.js app with Prisma to Koyeb. +Congratulations! You have successfully deployed a Node.js app with Prisma ORM to Koyeb. You can find the source code for the example in [this GitHub repository](https://github.com/koyeb/example-prisma). diff --git a/content/200-orm/200-prisma-client/500-deployment/101-traditional/index.mdx b/content/200-orm/200-prisma-client/500-deployment/101-traditional/index.mdx index 145b8aa5a9..b0b4a564ae 100644 --- a/content/200-orm/200-prisma-client/500-deployment/101-traditional/index.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/101-traditional/index.mdx @@ -1,6 +1,6 @@ --- title: 'Traditional servers' -metaTitle: 'Deploy Prisma apps to traditional (PaaS) servers' +metaTitle: 'Deploy Prisma ORM apps to traditional (PaaS) servers' metaDescription: 'Learn how to deploy your Prisma-backed apps to PaaS providers like Heroku, Koyeb, or AWS EC2' tocDepth: 2 --- diff --git a/content/200-orm/200-prisma-client/500-deployment/201-serverless/150-deploy-to-azure-functions.mdx b/content/200-orm/200-prisma-client/500-deployment/201-serverless/150-deploy-to-azure-functions.mdx index 75dbd7c813..176b49ca44 100644 --- a/content/200-orm/200-prisma-client/500-deployment/201-serverless/150-deploy-to-azure-functions.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/201-serverless/150-deploy-to-azure-functions.mdx @@ -1,7 +1,7 @@ --- title: 'Deploy to Azure Functions' -metaTitle: 'How to deploy an app using Prisma to Azure Functions' -metaDescription: 'Learn how to deploy a Prisma based REST API to Azure Functions and connect to an Azure SQL database' +metaTitle: 'How to deploy an app using Prisma ORM to Azure Functions' +metaDescription: 'Learn how to deploy a Prisma Client based REST API to Azure Functions and connect to an Azure SQL database' --- @@ -14,11 +14,11 @@ Azure Functions is a serverless deployment platform. You do not need to maintain ## Prerequisites -- An existing function app project with Prisma +- An existing function app project with Prisma ORM ## Things to know -While Prisma works well with Azure functions, there are a few things to take note of before deploying your application. +While Prisma ORM works well with Azure functions, there are a few things to take note of before deploying your application. ### Define multiple binary targets @@ -33,7 +33,7 @@ generator client { ### Connection pooling -Generally, when you use a FaaS (Function as a Service) environment to interact with a database, every function invocation can result in a new connection to the database. This is not a problem with a constantly running Node.js server. Therefore, it is beneficial to pool DB connections to get better performance. To solve this issue, you can use the [Data Proxy](/platform/classic-projects/data-proxy). For other solutions, see the [connection management guide for serverless environments](/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). +Generally, when you use a FaaS (Function as a Service) environment to interact with a database, every function invocation can result in a new connection to the database. This is not a problem with a constantly running Node.js server. Therefore, it is beneficial to pool DB connections to get better performance. To solve this issue, you can use the [Prisma Accelerate](/accelerate). For other solutions, see the [connection management guide for serverless environments](/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). ## Summary 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 f62f86db43..dd6d859654 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 @@ -16,9 +16,9 @@ While our examples use Next.js, you can deploy other applications to Vercel. See -## Generate Prisma during build +## Generate Prisma ORM during build -Vercel will automatically cache dependencies on deployment. For most applications, this will not cause any issues. However, for Prisma, it may result in an outdated version of Prisma Client on a change in your Prisma schema. To avoid this issue, add `prisma generate` to the `postinstall` script of your application: +Vercel will automatically cache dependencies on deployment. For most applications, this will not cause any issues. However, for Prisma ORM, it may result in an outdated version of Prisma Client on a change in your Prisma schema. To avoid this issue, add `prisma generate` to the `postinstall` script of your application: ```json file=package.json highlight=4;add { 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 471160e825..ec97856462 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 @@ -1,19 +1,19 @@ --- title: 'Deploy to AWS Lambda' -metaTitle: 'Deploy your application using Prisma to AWS Lambda' -metaDescription: 'Learn how to deploy your Prisma-backed applications to AWS Lambda with AWS SAM, Serverless Framework, or SST' +metaTitle: 'Deploy your application using Prisma ORM to AWS Lambda' +metaDescription: 'Learn how to deploy your Prisma ORM-backed applications to AWS Lambda with AWS SAM, Serverless Framework, or SST' tocDepth: 3 --- -This guide explains how to avoid common issues when deploying a project using Prisma to [AWS Lambda](https://aws.amazon.com/lambda/). +This guide explains how to avoid common issues when deploying a project using Prisma ORM to [AWS Lambda](https://aws.amazon.com/lambda/). While a deployment framework is not required to deploy to AWS Lambda, this guide covers deploying with: - [AWS Serverless Application Model (SAM)](https://aws.amazon.com/serverless/sam/) is an open-source framework from AWS that can be used in the creation of serverless applications. AWS SAM includes the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-reference.html#serverless-sam-cli), which you can use to build, test, and deploy your application. -- [Serverless Framework](https://www.serverless.com/framework/) provides a CLI that helps with workflow automation and AWS resource provisioning. While Prisma works well with the Serverless Framework "out of the box", there are a few improvements that can be made within your project to ensure a smooth deployment and performance. There is also additional configuration that is needed if you are using the [`serverless-webpack`](https://www.npmjs.com/package/serverless-webpack) or [`serverless-bundle`](https://www.npmjs.com/package/serverless-bundle) libraries. -- [SST](https://sst.dev/) provides tools that make it easy for developers to define, test, debug, and deploy their applications. Prisma works well with SST but must be configured so that your schema is correctly packaged by SST. +- [Serverless Framework](https://www.serverless.com/framework/) provides a CLI that helps with workflow automation and AWS resource provisioning. While Prisma ORM works well with the Serverless Framework "out of the box", there are a few improvements that can be made within your project to ensure a smooth deployment and performance. There is also additional configuration that is needed if you are using the [`serverless-webpack`](https://www.npmjs.com/package/serverless-webpack) or [`serverless-bundle`](https://www.npmjs.com/package/serverless-bundle) libraries. +- [SST](https://sst.dev/) provides tools that make it easy for developers to define, test, debug, and deploy their applications. Prisma ORM works well with SST but must be configured so that your schema is correctly packaged by SST. @@ -27,13 +27,28 @@ This section covers changes you will need to make to your application, regardles ### Define binary targets in Prisma Schema -The Prisma schema should contain the following in the `generator` block: +Depending on the version of Node.js, your Prisma schema should contain either `rhel-openssl-1.0.x` or `rhel-openssl-3.0.x` in the `generator` block: + + + + ```prisma binaryTargets = ["native", "rhel-openssl-1.0.x"] ``` -This is necessary because the runtimes used in development and deployment differ. Add the [`binaryTarget`](/orm/reference/prisma-schema-reference#binarytargets-options) to make the compatible Prisma engine file available. + + + +```prisma +binaryTargets = ["native", "rhel-openssl-3.0.x"] +``` + + + + + +This is necessary because the runtimes used in development and deployment differ. Add the [`binaryTarget`](/orm/reference/prisma-schema-reference#binarytargets-options) to make the compatible Prisma ORM engine file available. #### Lambda functions with arm64 architectures @@ -73,9 +88,9 @@ AWS SAM does not directly support loading values from a `.env` file. You will ha ### Loading required files -AWS SAM uses [esbuild](https://esbuild.github.io/) to bundle your TypeScript code. However, the full esbuild API is not exposed and esbuild plugins are not supported. This leads to problems when using Prisma in your application as certain files (like `schema.prisma`) must be available at runtime. +AWS SAM uses [esbuild](https://esbuild.github.io/) to bundle your TypeScript code. However, the full esbuild API is not exposed and esbuild plugins are not supported. This leads to problems when using Prisma ORM in your application as certain files (like `schema.prisma`) must be available at runtime. -To get around this, you need to directly reference the needed files in your code to bundle them correctly. In your application, you could add the following lines to your application where Prisma is instantiated. +To get around this, you need to directly reference the needed files in your code to bundle them correctly. In your application, you could add the following lines to your application where Prisma ORM is instantiated. ```ts file=app.ts import schema from './prisma/schema.prisma' @@ -95,7 +110,7 @@ Loader: AssetNames: '[name]' ``` -This will make sure that files needed by Prisma will be included in the AWS SAM build. +This will make sure that files needed by Prisma ORM will be included in the AWS SAM build. ## Deploying with the Serverless Framework @@ -144,7 +159,7 @@ Packaging deployment-example-sls for stage dev (us-east-1) ### Deploy only the required files -To reduce your deployment footprint, you can update your deployment process to only upload the files your application needs. The Serverless configuration file, `serverless.yml`, below shows a `package` pattern that includes only the Prisma engine file relevant to the Lambda runtime and excludes the others. This means that when Serverless Framework packages your app for upload, it includes only one engine file. This ensures the packaged archive is as small as possible. +To reduce your deployment footprint, you can update your deployment process to only upload the files your application needs. The Serverless configuration file, `serverless.yml`, below shows a `package` pattern that includes only the Prisma ORM engine file relevant to the Lambda runtime and excludes the others. This means that when Serverless Framework packages your app for upload, it includes only one engine file. This ensures the packaged archive is as small as possible. ```code file=serverless.yml no-copy package: @@ -174,7 +189,7 @@ If you use `serverless-webpack`, you will need additional configuration so that 1. Copy your `schema.prisma` with [`copy-webpack-plugin`](https://www.npmjs.com/package/copy-webpack-plugin). 2. Run `prisma generate` via `custom > webpack > packagerOptions > scripts` in your `serverless.yml`. -3. Only package the correct Prisma engine file to save more than 40mb of capacity. +3. Only package the correct Prisma ORM engine file to save more than 40mb of capacity. #### 1. Install webpack specific dependencies @@ -218,7 +233,7 @@ module.exports = { } ``` -This plugin will allow you to copy your `schema.prisma` file into your bundled code. Prisma requires that your `schema.prisma` be present in order make sure that queries are encoded and decoded according to your schema. In most cases, bundlers will not include this file by default and will cause your application to fail to run. +This plugin will allow you to copy your `schema.prisma` file into your bundled code. Prisma ORM requires that your `schema.prisma` be present in order make sure that queries are encoded and decoded according to your schema. In most cases, bundlers will not include this file by default and will cause your application to fail to run. @@ -242,7 +257,7 @@ custom: This will ensure that, after webpack bundles your code, the Prisma Client is generated according to your schema. Without this step, your app will fail to run. -Lastly, you will want to exclude [Prisma query engines](/orm/more/under-the-hood/engines) that do not match the AWS Lambda runtime. Update your `serverless.yml` by adding the following script that makes sure only the required query engine, `rhel-openssl-1.0.x`, is included in the final packaged archive. +Lastly, you will want to exclude [Prisma ORM query engines](/orm/more/under-the-hood/engines) that do not match the AWS Lambda runtime. Update your `serverless.yml` by adding the following script that makes sure only the required query engine, `rhel-openssl-1.0.x`, is included in the final packaged archive. ```yaml file=serverless.yml highlight=6;add custom: diff --git a/content/200-orm/200-prisma-client/500-deployment/201-serverless/500-deploy-to-netlify.mdx b/content/200-orm/200-prisma-client/500-deployment/201-serverless/500-deploy-to-netlify.mdx index c0aabfe6cd..d984de1a68 100644 --- a/content/200-orm/200-prisma-client/500-deployment/201-serverless/500-deploy-to-netlify.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/201-serverless/500-deploy-to-netlify.mdx @@ -6,7 +6,7 @@ metaDescription: 'Learn how to deploy Node.js and TypeScript applications that a -This guide covers the steps you will need to take in order to deploy your application that uses Prisma to [Netlify](https://www.netlify.com/). +This guide covers the steps you will need to take in order to deploy your application that uses Prisma ORM to [Netlify](https://www.netlify.com/). Netlify is a cloud platform for continuous deployment, static sites, and serverless functions. Netlify integrates seamlessly with GitHub for automatic deployments upon commits. When you follow the steps below, you will use that approach to create a CI/CD pipeline that deploys your application from a GitHub repository. @@ -20,12 +20,27 @@ Before you can follow this guide, you will need to set up your application to be Since your code is being deployed to Netlify's environment, which isn't necessarily the same as your development environment, you will need to set [`binaryTargets`](/orm/reference/prisma-schema-reference#binarytargets-options) in order to download the query engine that is compatible with the Netlify runtime during your build step. If you do not set this option, your deployed code will have an incorrect query engine deployed with it and will not function. -You should update your Prisma schema to contain the following in the `generator` block: +Depending on the version of Node.js, your Prisma schema should contain either `rhel-openssl-1.0.x` or `rhel-openssl-3.0.x` in the `generator` block: + + + + ```prisma binaryTargets = ["native", "rhel-openssl-1.0.x"] ``` + + + +```prisma +binaryTargets = ["native", "rhel-openssl-3.0.x"] +``` + + + + + ## Store environment variables in Netlify We recommend keeping `.env` files in your `.gitignore` in order to prevent leakage of sensitives connection strings. Instead, you can use the Netlify CLI to [import values into netlify directly](https://docs.netlify.com/environment-variables/get-started/#import-variables-with-the-netlify-cli). diff --git a/content/200-orm/200-prisma-client/500-deployment/201-serverless/index.mdx b/content/200-orm/200-prisma-client/500-deployment/201-serverless/index.mdx index 7aa4a9f808..4593419b25 100644 --- a/content/200-orm/200-prisma-client/500-deployment/201-serverless/index.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/201-serverless/index.mdx @@ -1,7 +1,7 @@ --- title: 'Serverless functions' -metaTitle: 'Deploy Prisma apps to serverless function (FaaS) providers' -metaDescription: 'Learn how to deploy your Prisma-backed apps to FaaS providers like AWS Lambda, Netlify, or Vercel Serverless Functions' +metaTitle: 'Deploy Prisma ORM apps to serverless function (FaaS) providers' +metaDescription: 'Learn how to deploy your Prisma ORM-backed apps to FaaS providers like AWS Lambda, Netlify, or Vercel Serverless Functions' tocDepth: 2 --- diff --git a/content/200-orm/200-prisma-client/500-deployment/210-module-bundlers.mdx b/content/200-orm/200-prisma-client/500-deployment/210-module-bundlers.mdx deleted file mode 100644 index c775b0dceb..0000000000 --- a/content/200-orm/200-prisma-client/500-deployment/210-module-bundlers.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: 'Module bundlers' -metaTitle: 'Module bundlers (Reference)' -metaDescription: 'This page gives an overview of the most important things to be aware of when using a module bundler to bundle an application that uses Prisma Client.' ---- - -## Overview - -_Module bundlers_ bundle JavaScript modules into a single JavaScript file. Most bundlers work by copying over the JavaScript code from a variety of source files into the target file. - -Since Prisma Client is not only based on JavaScript code, but also relies on the [**query engine binary file**](/orm/more/under-the-hood/engines#the-query-engine-file) to be available, you need to make sure that your bundled code has access to the binary file. - -To do so, you can use plugins that let you copy over static assets: - -| Bundler | Plugin | -| :------ | :------------------------------------------------------------------------------------------------------ | -| Webpack | [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin#copy-webpack-plugin) | -| Parcel | [`parcel-plugin-static-files-copy`](https://github.com/elwin013/parcel-plugin-static-files-copy#readme) | diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/100-overview.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/100-overview.mdx new file mode 100644 index 0000000000..6d152f79f9 --- /dev/null +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/100-overview.mdx @@ -0,0 +1,58 @@ +--- +title: 'Overview' +metaTitle: 'Overview (Deploy Prisma ORM at the Edge)' +metaDescription: 'Learn how to deploy your Prisma-backed apps to edge functions like Cloudflare Workers or Vercel Edge Functions' +tocDepth: 2 +--- + +## Deploying edge functions with Prisma ORM + +You can deploy an application that uses Prisma ORM to the edge. Depending on which edge function provider and which database you use, there are different considerations and things to be aware of. + +Here is a brief overview of all the edge function providers that are currently supported by Prisma ORM: + +| Provider / Product | Supported natively with Prisma ORM | Supported with Prisma Accelerate | +| ---------------------- | ------------------------------------------------------- | -------------------------------- | +| Vercel Edge Functions | ✅ (Preview; only compatible drivers) | ✅ | +| Vercel Edge Middleware | ✅ (Preview; only compatible drivers) | ✅ | +| Cloudflare Workers | ✅ (Preview; only compatible drivers) | ✅ | +| Cloudflare Pages | ✅ (Preview; only compatible drivers) | ✅ | +| Deno Deploy | [Not yet](https://github.com/prisma/prisma/issues/2452) | ✅ | + +Deploying edge functions that use Prisma ORM on Cloudflare and Vercel is currently in [Preview](/orm/more/releases#preview). + +## Edge-compatibility of database drivers + +### Why are there limitations around database drivers in edge functions? + +Edge functions typically don't use the standard Node.js runtime. For example, Vercel Edge Functions and Cloudflare Workers are running code in [V8 isolates](https://v8docs.nodesource.com/node-0.8/d5/dda/classv8_1_1_isolate.html). Deno Deploy is using the [Deno](https://deno.com/) JavaScript runtime. As a consequence, these edge functions only have access to a small subset of the standard Node.js APIs and also have constrained computing resources (CPU and memory). + +In particular, the constraint of not being able to freely open TCP connections makes it difficult to talk to a traditional database from an edge function. While Cloudflare has introduced a [`connect()`](https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/) API that enables limited TCP connections, this still only enables database access using specific database drivers that are compatible with that API. + +> **Note**: [Prisma Accelerate](/accelerate) enables you to access _any_ database from _any_ edge function provider. No edge-compatible driver is necessary. + +### Which database drivers are edge-compatible? + +Here is an overview of the different database drivers and their compatibility with different edge function offerings: + +- [Neon Serverless](https://neon.tech/docs/serverless/serverless-driver) uses HTTP to access the database. It works with Cloudflare Workers and Vercel Edge Functions. +- [PlanetScale Serverless](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) uses HTTP to access the database. It works with Cloudflare Workers and Vercel Edge Functions. +- [`node-postgres`](https://node-postgres.com/) (`pg`) uses Cloudflare's `connect()` (TCP) to access the database. It is only compatible with Cloudflare Workers, not with Vercel Edge Functions. +- [`@libsql/client`](https://github.com/tursodatabase/libsql-client-ts) is used to access Turso databases. It works with Cloudflare Workers and Vercel Edge Functions. + +There's [also work being done](https://github.com/sidorares/node-mysql2/pull/2289) on the `node-mysql2` driver which will enable access to traditional MySQL databases from Cloudflare Workers and Pages in the future as well. + +You can use all of these drivers with Prisma ORM using the respective [driver adapters](/orm/overview/databases/database-drivers). + +Depending on which deployment provider and database/driver you use, there may be special considerations. Please take a look at the deployment docs for your respective scenario to make sure you can deploy your application successfully: + +- Cloudflare + - [PostgreSQL (traditional)](/orm/prisma-client/deployment/edge/deploy-to-cloudflare#postgresql-traditional) + - [PlanetScale](/orm/prisma-client/deployment/edge/deploy-to-cloudflare#planetscale) + - [Neon](/orm/prisma-client/deployment/edge/deploy-to-cloudflare#neon) +- Vercel + - [Vercel Postgres](/orm/prisma-client/deployment/edge/deploy-to-vercel#vercel-postgres) + - [Neon](/orm/prisma-client/deployment/edge/deploy-to-vercel#neon) + - [PlanetScale](/orm/prisma-client/deployment/edge/deploy-to-vercel#planetscale) + +If you want to deploy an app using Turso, you can follow the instructions [here](/orm/overview/databases/turso). diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare-workers.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare-workers.mdx deleted file mode 100644 index 42dffa603a..0000000000 --- a/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare-workers.mdx +++ /dev/null @@ -1,309 +0,0 @@ ---- -title: 'Deploy to Cloudflare Workers' -metaTitle: 'Deploy to Cloudflare Workers' -metaDescription: 'Learn how to deploy a TypeScript application to Cloudflare Workers that connects to PostgreSQL.' ---- - - - -Today you'll be deploying a Cloudflare Worker that uses Prisma to save every request to a PostgreSQL database and fetches 20 of the most recent logs. - -This guide covers Prisma, TypeScript, PostgreSQL, Prisma Accelerate, and Cloudflare Workers. - - - -## Prerequisites - -- A PostgreSQL database that is publicly accessible -- [Cloudflare Workers](https://workers.cloudflare.com/) account -- [Prisma Data Platform](https://console.prisma.io/) account -- Node.js & npm installed -- Git installed - -## 1. Set up your application - -Wrangler is the official Cloudflare Worker CLI. You will use it to develop and deploy to Cloudflare Workers. This guide uses [Wrangler v3](https://developers.cloudflare.com/workers/wrangler/). - -Open your terminal and navigate to a location of your choice. First, initialize your project using the [create-cloudflare-cli](https://www.npmjs.com/package/create-cloudflare). To do this, run the following command in your terminal: - -```terminal -npm create cloudflare@latest -``` - -This will ask you a few questions. - -```terminal -In which directory do you want to create your application? -``` - -Enter the name of your project, for example: `prisma-cloudflare-accelerate` - -```terminal -What type of application do you want to create? -``` - -Select the `"Hello World" Worker` option. - -```terminal -Would you like to use TypeScript? (y/n) -``` - -We also want to use TypeScript, so answer yes. - -```terminal -Would you like to use git to manage this Worker? (y/n) -``` - -We want to use Git, so answer yes. - -The command this will create a new project with a minimal preset configuration. Once `create-cloudflare-cli` is done, navigate to the project and open it on your editor of choice. - -Next, authenticate the Wrangler CLI with your Cloudflare Workers account. To do this, run the following command in your terminal: - -```terminal -npx wrangler login -``` - -You can now verify that you're logged in by running `npx wrangler whoami`. - -```terminal -npx wrangler whoami -``` - -## 2. Set up Prisma - -Now you're ready to add Prisma to the project. - -Install `prisma` as a development dependency: - -```terminal -npm install --save-dev prisma -``` - -Next, initialize Prisma in your project with the following command: - -```terminal -npx prisma init -``` - -This creates a Prisma schema in `prisma/schema.prisma`. - - - -**Note:**

- -`prisma init` also creates an `.env` file. The `.env` file will contain a placeholder `DATABASE_URL` variable that will be used to update your database schema using Prisma Migrate. Update this value with your database's connection string. - -
- -Update your Prisma schema with the following data model: - -```prisma -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model Log { - id Int @id @default(autoincrement()) - level Level - message String - meta Json -} - -enum Level { - Info - Warn - Error -} -``` - -The above data model will be used to persist and retrieve logs from your Cloudflare Worker - -## 3. Update your database schema - -To map your data model to the database schema, you need to use the `prisma migrate dev` CLI command: - -```terminal -npx prisma migrate dev --name init -``` - -The command does two things: - -1. It creates a new SQL migration file for this migration -1. It runs the SQL migration file against the database - -## 4. Enable Accelerate in the Prisma Data Platform - -Prisma currently does not work on Cloudflare Workers yet. However, you can use Prisma on Cloudflare Workers through [Prisma Accelerate](/accelerate). - -To get started with Prisma Accelerate: - -1. Sign up for a free [Prisma Data Platform account](https://console.prisma.io/) -1. Create a project -1. Navigate to the project you created -1. Enable Accelerate -1. Generate an Accelerate connection string and copy it to your clipboard - -## 5. Configure the Accelerate connection string in your project - -1. Rename the existing `DATABASE_URL` environment variable to `DIRECT_URL`. The `DIRECT_URL` variable will be used perform migrations and introspections. -1. Add the Prisma Accelerate connection string to your `.env` file. - - ```diff file=.env - -DATABASE_URL="postgres://..." - +DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=__API_KEY__" - +DIRECT_URL="postgres://..." - ``` - - Add [`directUrl`](/orm/reference/prisma-schema-reference#fields) property in `datasource` block in the `schema.prisma` file. - - ```prisma highlight=4;add file=prisma/schema.prisma - datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - directUrl = env("DIRECT_URL") - } - ``` - - > The `directUrl` field is not required for Prisma Accelerate. It allows you to introspect and perform schema migrations. - -1. In `wrangler.toml` file, add a `[vars]` key and your connection string. - - ```diff file=wrangler.toml - name = "prisma-cloudflare-accelerate" - main = "src/main.ts" - compatibility_date = "2022-11-07" - - + [vars] - + DATABASE_URL = "prisma://accelerate.prisma-data.net/?api_key=__API_KEY__" - ``` - - - - Cloudflare Workers does not support `.env` files. To set environment variables, you can either adding the `[vars]` key in your `wrangler.toml` file or saving your environment variables in a `.dev.vars` file. Refer to [Cloudflare's documentation](https://developers.cloudflare.com/pages/platform/functions/bindings/#interact-with-your-environment-variables-locally) to learn more. - - - -1. Install the Prisma Accelerate extension - - ```bash - npm install @prisma/extension-accelerate - ``` - -You are now ready to generate a Prisma Client. - -## 6. Generate a Prisma Client - -Next, generate Prisma Client that connects to your database through [Prisma Accelerate](/accelerate) over HTTP. - -```terminal -npx prisma generate --no-engine -``` - - - -The `--no-engine` flag is available from Prisma 5.2.0 and later. If you're using an earlier version of Prisma, use the `--accelerate` flag. - -```terminal -npx prisma generate --accelerate -``` - - - -The generated Client has a smaller bundle size and is optimized for edge environments like Cloudflare Workers. - -The smaller bundle size is due to the fact that the interfaces talking to the database (the [Prisma engines](/orm/more/under-the-hood/engines)) are no longer bundled with Prisma Client as this logic is now handled by Prisma Accelerate. - -## 7. Develop the Cloudflare Worker function - -You're now ready to create a Cloudflare Worker. Create a `src/index.ts` file with the following code: - -```ts -import { PrismaClient } from '@prisma/client/edge' -import { withAccelerate } from '@prisma/extension-accelerate' - -export interface Env { - DATABASE_URL: string -} - -export default { - async fetch( - request: Request, - env: Env, - ctx: ExecutionContext - ): Promise { - const prisma = new PrismaClient({ - datasourceUrl: env.DATABASE_URL, - }).$extends(withAccelerate()) - - await prisma.log.create({ - data: { - level: 'Info', - message: `${request.method} ${request.url}`, - meta: { - headers: JSON.stringify(request.headers), - }, - }, - }) - - const { data, info } = await prisma.log - .findMany({ - take: 20, - orderBy: { - id: 'desc', - }, - }) - .withAccelerateInfo() - - console.log(JSON.stringify(info)) - - return new Response(`request method: ${request.method}!`) - }, -} -``` - -> The [`info`](/accelerate/api-reference#return-type) object has additional information which can be useful for debugging. -> Accelerate can also be used to cache your query results. You can find more information on caching with Prisma Accelerate in [here](/accelerate). - -Run `npm run dev` to see your worker in development: - -``` -👂 Listening on http://127.0.0.1:8787 -``` - -Go ahead and open `http://127.0.0.1:8787`. If all goes well, you should see: - -``` -request method: GET! -``` - -Refresh the page a couple times to verify that it's working. - -## 8. Publish to Cloudflare Workers - -You're now ready to deploy to Cloudflare Workers. Run the following command: - -```terminal -npm run deploy -``` - -This will package and upload to Cloudflare. With a bit of luck, you'll see the following: - -``` -✨ Built successfully, built project size is 94 KiB. -✨ Successfully published your script to -https://prisma-cloudflare-accelerate.ankman.workers.dev -``` - -Visit your deployment URL and you'll again see: - -``` -request method: GET! -``` - -You're all set! You've successfully deployed a Cloudflare Worker written in TypeScript that uses Prisma to talk to your PostgreSQL database. 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 new file mode 100644 index 0000000000..a00ed6bf88 --- /dev/null +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx @@ -0,0 +1,541 @@ +--- +title: 'Deploy to Cloudflare Workers & Pages' +navTitle: Deploy to Cloudflare +metaTitle: 'Deploy to Cloudflare Workers & Pages' +metaDescription: 'Learn the things you need to know in order to deploy an app that uses Prisma Client for talking to a database to a Cloudflare Worker or to Cloudflare Pages.' +tocDepth: 3 +preview: true +--- + + + +This page covers everything you need to know to deploy an app with Prisma ORM to a [Cloudflare Worker](https://developers.cloudflare.com/workers/) or to [Cloudflare Pages](https://developers.cloudflare.com/pages). + + + +## General considerations when deploying to Cloudflare Workers + +This section covers _general_ things you need to be aware of when deploying to Cloudflare Workers or Pages and are using Prisma ORM, regardless of the database provider you use. + +### Using an edge-compatible driver + +When deploying a Cloudflare Worker that uses Prisma ORM, you need to use an [edge-compatible driver](/orm/prisma-client/deployment/edge/overview#edge-compatibility-of-database-drivers) and its respective [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) for Prisma ORM. + +The edge-compatible drivers for Cloudflare Workers and Pages are: + +- [Neon Serverless](https://neon.tech/docs/serverless/serverless-driver) uses HTTP to access the database +- [PlanetScale Serverless](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) uses HTTP to access the database +- [`node-postgres`](https://node-postgres.com/) (`pg`) uses Cloudflare's `connect()` (TCP) to access the database +- [`@libsql/client`](https://github.com/tursodatabase/libsql-client-ts) is used to access Turso databases + +There's [also work being done](https://github.com/sidorares/node-mysql2/pull/2289) on the `node-mysql2` driver which will enable access to traditional MySQL databases from Cloudflare Workers and Pages in the future as well. + +> **Note**: [Prisma Accelerate](/accelerate) enables you to access _any_ database from _any_ edge function provider. No edge-compatible driver is necessary. + +### 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: + +```prisma +datasource db { + provider = "postgresql" // this might also be `mysql` or another value depending on your database + 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/#secrets-in-development) locally. + +Assuming you use the `DATABASE_URL` environment variable from above, you can set it inside `.dev.vars` as follows: + +```bash file=.dev.vars +DATABASE_URL="your-database-connection-string" +``` + +In the above snippet, `your-database-connection-string` is a placeholder that you need to replace with the value of your own connection string, for example: + +```bash file=.dev.vars +DATABASE_URL="postgresql://admin:mypassword42@somehost.aws.com:5432/mydb" +``` + +Note that the `.dev.vars` file is not compatible with `.env` files which are typically used by Prisma ORM. + +This means that you need to make sure that Prisma ORM gets access to the environment variable when needed, e.g. when running a Prisma CLI command like `prisma migrate dev`. + +There are several options for achieving this: + +- Run your Prisma CLI commands using [`dotenv`](https://www.npmjs.com/package/dotenv-cli) to specify from where the CLI should read the environment variable, for example: + ```terminal + dotenv -e .dev.vars -- npx prisma migrate dev + ``` +- Create a script in `package.json` that reads `.dev.vars` via [`dotenv`](https://www.npmjs.com/package/dotenv-cli). You can then execute `prisma` commands as follows: `npm run env -- npx prisma migrate dev`. Here's a reference for the script: + ```js file=package.json + "scripts": { "env": "dotenv -e .dev.vars" } + ``` +- Duplicate the `DATABASE_URL` and any other relevant env vars into a new file called `.env` which can then be used by Prisma ORM. + +> **Note**: If you're using an approach that requires `dotenv`, you need to have the [`dotenv-cli`](https://www.npmjs.com/package/dotenv-cli) package installed. You can do this e.g. by using this command to install the package locally in your project: `npm install -D dotenv-cli`. + +#### Production + +When deploying your Worker to **production**, you'll need to set the database connection using the `wrangler` CLI: + +```terminal +npx wrangler secret put DATABASE_URL +``` + +The command is interactive and will ask you to enter the value for the `DATABASE_URL` env var as the next step in the terminal. + +> **Note**: This command requires you to be authenticated, and will ask you to log in to your Cloudflare account in case you are not. + +### Size limits on free accounts + +Cloudflare has a [size limit of 1 MB for Workers on the free plan](https://developers.cloudflare.com/workers/platform/limits/). If your application bundle with Prisma ORM exceeds that size, we recommend upgrading to a paid Worker plan or using Prisma Accelerate to deploy your application. + +If you're running into this problem with `pg` and the `@prisma/adapter-pg` package, you can replace the `pg` with the custom [`@prisma/pg-worker`](https://github.com/prisma/prisma/tree/main/packages/pg-worker) package and use the [`@prisma/adapter-pg-worker`](https://github.com/prisma/prisma/tree/main/packages/adapter-pg-worker) adapter that belongs to it. + +`@prisma/pg-worker` is an optimized and lightweight version of `pg` that is designed to be used in a Worker. It is a drop-in replacement for `pg` and is fully compatible with Prisma ORM. + +### Deploying a Next.js app with `@cloudflare/next-on-pages` + +Cloudflare offers an option to run Next.js apps on Cloudflare Pages with [`@cloudflare/next-on-pages`](https://github.com/cloudflare/next-on-pages), see the [docs](https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site) for instructions. + +Based on some testing, we found the following: + +- You can deploy using the PlanetScale Serverless Driver. +- Neon currently doesn't work because of a probable bug in `@cloudflare/next-on-pages` (see [here](https://github.com/cloudflare/next-on-pages/issues/499#issuecomment-1863613990) and [here](https://github.com/cloudflare/workerd/issues/1513)). +- Traditional PostgreSQL deployments using `pg` don't work because `pg` itself currently does not work on `@cloudflare/next-on-pages` (see [here](https://github.com/cloudflare/next-on-pages/issues/605)). + +Feel free to reach out to us on [Discord](https://pris.ly/discord) if you find that anything has changed about this. + +### Set `PRISMA_CLIENT_FORCE_WASM=1` when running locally with `node` + +Some frameworks (e.g. [hono](https://hono.dev/)) use `node` instead of `wrangler` for running Workers locally. If you're using such a framework or are running your Worker locally with `node` for another reason, you need to set the `PRISMA_CLIENT_FORCE_WASM` environment variable: + +``` +export PRISMA_CLIENT_FORCE_WASM=1 +``` + +## Database-specific considerations & examples + +This section provides database-specific instructions for deploying a Cloudflare Worker with Prisma ORM. + +### Prerequisites + +As a prerequisite for the following section, you need to have a Cloudflare Worker running locally and the Prisma CLI installed. + +If you don't have that yet, you can run these commands: + +```terminal +npm create cloudflare@latest prisma-cloudflare-worker-example -- --type hello-world +cd prisma-cloudflare-worker-example +npm install prisma --save-dev +npx prisma init +``` + +We'll use the default `User` model for the example below: + +```prisma +model User { + id Int @id @default(autoincrement()) + email String @unique + name String? +} +``` + +### PostgreSQL (traditional) + +If you are using a traditional PostgreSQL database that's accessed via TCP and the `pg` driver, you need to: + +- use the `@prisma/adapter-pg` database adapter (via the `driverAdapters` Preview feature) +- set `node_compat = true` in `wrangler.toml` (see the [Cloudflare docs](https://developers.cloudflare.com/workers/wrangler/configuration/#add-polyfills-using-wrangler)) + +If you are running into a size issue and can't deploy your application because of that, you can use our slimmer variant of the `pg` driver package [`@prisma/pg-worker`](https://github.com/prisma/prisma/tree/main/packages/pg-worker) and the [`@prisma/adapter-pg-worker`](https://github.com/prisma/prisma/tree/main/packages/adapter-pg-worker) adapter that belongs to it. + +`@prisma/pg-worker` is an optimized and lightweight version of `pg` that is designed to be used in a Worker. It is a drop-in replacement for `pg` and is fully compatible with Prisma ORM. + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "postgresql" + 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 +DATABASE_URL="postgresql://admin:mypassword42@somehost.aws.com:5432/mydb" +``` + +Because the Prisma CLI by default is only compatible with `.env` files, you can adjust your `package.json` with the following script that loads the env vars from `.dev.vars`. You can then use this script to load the env vars before executing a `prisma` command. + +Add this script to your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // .... + "env": "dotenv -e .dev.vars" + }, + // ... +} +``` + +Now you can execute Prisma CLI commands as follows while ensuring that the command has access to the env vars in `.dev.vars`: + +```terminal +npm run env -- npx prisma +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-pg +npm install pg +npm install @types/pg --save-dev # if you're using TypeScript +``` + +#### 3. Set `node_compat = true` in `wrangler.toml` + +In your `wrangler.toml` file, add the following line: + +```toml file=wrangler.toml +node_compat = true +``` + +> **Note**: For Cloudflare Pages, using `node_compat` is not officially supported. If you want to use `pg` in Cloudflare Pages, you can find a workaround [here](https://github.com/cloudflare/workers-sdk/pull/2541#issuecomment-1954209855). + +#### 4. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npm run env -- npx prisma migrate dev --name init +``` + +#### 5. Use Prisma Client in your Worker to send a query to the database + +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 { PrismaPg } from '@prisma/adapter-pg' +import { Pool } from 'pg' + +export default { + async fetch(request, env, ctx) { + const pool = new Pool({ connectionString: env.DATABASE_URL }) + const adapter = new PrismaPg(pool) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + const result = JSON.stringify(users) + return new Response(result) + }, +} +``` + +#### 6. Run the Worker locally + +To run the Worker locally, you can run the `wrangler dev` command: + +```terminal +npx wrangler dev +``` + +#### 7. Set the `DATABASE_URL` environment variable and deploy the Worker + +To deploy the Worker, you first need to the `DATABASE_URL` environment variable [via the `wrangler` CLI](https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-deployed-workers): + +```terminal +npx wrangler secret put DATABASE_URL +``` + +The command is interactive and will ask you to enter the value for the `DATABASE_URL` env var as the next step in the terminal. + +> **Note**: This command requires you to be authenticated, and will ask you to log in to your Cloudflare account in case you are not. + +Then you can go ahead then deploy the Worker: + +```terminal +npx wrangler deploy +``` + +The command will output the URL where you can access the deployed Worker. + +### PlanetScale + +If you are using a PlanetScale database, you need to: + +- use the `@prisma/adapter-planetscale` database adapter (via the `driverAdapters` Preview feature) +- manually remove the conflicting `cache` field ([learn more]()): + + ```ts + export default { + async fetch(request, env, ctx) { + const client = new Client({ + url: env.DATABASE_URL, + // see https://github.com/cloudflare/workerd/issues/698 + fetch(url, init) { + delete init['cache'] + return fetch(url, init) + }, + }) + const adapter = new PrismaPlanetScale(client) + const prisma = new PrismaClient({ adapter }) + + // ... + }, + } + ``` + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "mysql" + url = env("DATABASE_URL") + relationMode = "prisma" // required for PlanetScale (as by default foreign keys are disabled) +} +``` + +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 +DATABASE_URL="mysql://32qxa2r7hfl3102wrccj:password@us-east.connect.psdb.cloud/demo-cf-worker-ps?sslaccept=strict" +``` + +Because the Prisma CLI by default is only compatible with `.env` files, you can adjust your `package.json` with the following script that loads the env vars from `.dev.vars`. You can then use this script to load the env vars before executing a `prisma` command. + +Add this script to your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // .... + "env": "dotenv -e .dev.vars" + }, + // ... +} +``` + +Now you can execute Prisma CLI commands as follows while ensuring that the command has access to the env vars in `.dev.vars`: + +```terminal +npm run env -- npx prisma +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-planetscale +npm install @planetscale/database +``` + +#### 3. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npm run env -- npx prisma db push +``` + +#### 4. Use Prisma Client in your Worker to send a query to the database + +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 { PrismaPlanetScale } from '@prisma/adapter-planetscale' +import { Client } from '@planetscale/database' + +export default { + async fetch(request, env, ctx) { + const client = new Client({ + url: env.DATABASE_URL, + // see https://github.com/cloudflare/workerd/issues/698 + fetch(url, init) { + delete init['cache'] + return fetch(url, init) + }, + }) + const adapter = new PrismaPlanetScale(client) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + const result = JSON.stringify(users) + return new Response(result) + }, +} +``` + +#### 6. Run the Worker locally + +To run the Worker locally, you can run the `wrangler dev` command: + +```terminal +npx wrangler dev +``` + +#### 7. Set the `DATABASE_URL` environment variable and deploy the Worker + +To deploy the Worker, you first need to the `DATABASE_URL` environment variable [via the `wrangler` CLI](https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-deployed-workers): + +```terminal +npx wrangler secret put DATABASE_URL +``` + +The command is interactive and will ask you to enter the value for the `DATABASE_URL` env var as the next step in the terminal. + +> **Note**: This command requires you to be authenticated, and will ask you to log in to your Cloudflare account in case you are not. + +Then you can go ahead then deploy the Worker: + +```terminal +npx wrangler deploy +``` + +The command will output the URL where you can access the deployed Worker. + +### Neon + +If you are using a Neon database, you need to: + +- use the `@prisma/adapter-neon` database adapter (via the `driverAdapters` Preview feature) + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "postgresql" + 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 +DATABASE_URL="postgresql://janedoe:password@ep-nameless-pond-a23b1mdz.eu-central-1.aws.neon.tech/neondb?sslmode=require" +``` + +Because the Prisma CLI by default is only compatible with `.env` files, you can adjust your `package.json` with the following script that loads the env vars from `.dev.vars`. You can then use this script to load the env vars before executing a `prisma` command. + +Add this script to your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // .... + "env": "dotenv -e .dev.vars" + }, + // ... +} +``` + +Now you can execute Prisma CLI commands as follows while ensuring that the command has access to the env vars in `.dev.vars`: + +```terminal +npm run env -- npx prisma +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-neon +npm install @neondatabase/serverless +``` + +#### 3. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npm run env -- npx prisma migrate dev --name init +``` + +#### 5. Use Prisma Client in your Worker to send a query to the database + +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 { PrismaNeon } from '@prisma/adapter-neon' +import { Pool } from '@neondatabase/serverless' + +export default { + async fetch(request, env, ctx) { + const neon = new Pool({ connectionString: env.DATABASE_URL }) + const adapter = new PrismaNeon(neon) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + const result = JSON.stringify(users) + return new Response(result) + }, +} +``` + +#### 6. Run the Worker locally + +To run the Worker locally, you can run the `wrangler dev` command: + +```terminal +npx wrangler dev +``` + +#### 7. Set the `DATABASE_URL` environment variable and deploy the Worker + +To deploy the Worker, you first need to the `DATABASE_URL` environment variable [via the `wrangler` CLI](https://developers.cloudflare.com/workers/configuration/secrets/#secrets-on-deployed-workers): + +```terminal +npx wrangler secret put DATABASE_URL +``` + +The command is interactive and will ask you to enter the value for the `DATABASE_URL` env var as the next step in the terminal. + +> **Note**: This command requires you to be authenticated, and will ask you to log in to your Cloudflare account in case you are not. + +Then you can go ahead then deploy the Worker: + +```terminal +npx wrangler deploy +``` + +The command will output the URL where you can access the deployed Worker. + +### D1 + +[Coming soon](https://github.com/prisma/prisma/issues/13310). 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 new file mode 100644 index 0000000000..e2f234b39a --- /dev/null +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx @@ -0,0 +1,468 @@ +--- +title: 'Deploy to Vercel Edge Functions & Middleware' +navTitle: 'Deploy to Vercel' +metaTitle: 'Deploy to Vercel Edge Functions & Middleware' +metaDescription: 'Learn the things you need to know in order to deploy an Edge function that uses Prisma Client for talking to a database.' +tocDepth: 3 +preview: true +--- + + + +This page covers everything you need to know to deploy an app that uses Prisma Client for talking to a database in [Vercel Edge Middleware](https://vercel.com/docs/functions/edge-middleware) or a [Vercel Function](https://vercel.com/docs/functions) deployed to the [Vercel Edge Runtime](https://vercel.com/docs/functions/runtimes/edge-runtime). + +To deploy a Vercel Function to the Vercel Edge Runtime, you can set `export const runtime = 'edge'` outside the request handler of the Vercel Function. + + + +## General considerations when deploying to Vercel Edge Functions & Edge Middleware + +### Using an edge-compatible driver + +Vercel's Edge Runtime currently only supports a limited set of database drivers: + +- [Neon Serverless](https://neon.tech/docs/serverless/serverless-driver) uses HTTP to access the database (also compatible with [Vercel Postgres](https://vercel.com/docs/storage/vercel-postgres)) +- [PlanetScale Serverless](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) uses HTTP to access the database +- [`@libsql/client`](https://github.com/tursodatabase/libsql-client-ts) is used to access Turso databases + +Note that [`node-postgres`](https://node-postgres.com/) (`pg`) is currently _not_ supported on Vercel Edge Functions. + +When deploying a Vercel Edge Function that uses Prisma ORM, you need to use one of these [edge-compatible drivers](/orm/prisma-client/deployment/edge/overview#edge-compatibility-of-database-drivers) and its respective [driver adapter](/orm/overview/databases/database-drivers#driver-adapters) for Prisma ORM. + +> **Note**: [Prisma Accelerate](/accelerate) enables you to access _any_ database from _any_ edge function provider. No edge-compatible driver is necessary. + +### 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: + +```prisma +datasource db { + provider = "postgresql" // this might also be `mysql` or another value depending on your database + 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/env-files)). + +#### Production + +When deploying your Edge Function to **production**, you'll need to set the database connection using the `vercel` CLI: + +```terminal +npx vercel env add DATABASE_URL +``` + +This command is interactive and will ask you to select environments and provide the value for the `DATABASE_URL` in subsequent steps. + +Alternatively, you can configure the environment variable [via the UI](https://vercel.com/docs/projects/environment-variables#declare-an-environment-variable) of your project in the Vercel Dashboard. + +### Generate Prisma Client in `postinstall` hook + +In your `package.json`, you should add a `"postinstall"` section as follows: + +```js file=package.json +{ + // ..., + "postinstall: "prisma generate" +} +``` + +### Size limits on free accounts + +Vercel has a [size limit of 1 MB on free accounts](https://vercel.com/docs/functions/limitations). If your application bundle with Prisma ORM exceeds that size, we recommend upgrading to a paid account or using Prisma Accelerate to deploy your application. + +## Database-specific considerations & examples + +This section provides database-specific instructions for deploying a Vercel Edge Functions with Prisma ORM. + +### Prerequisites + +As a prerequisite for the following section, you need to have a Vercel Edge Function (which typically comes in the form of a Next.js API route) running locally and the Prisma and Vercel CLIs installed. + +If you don't have that yet, you can run these commands to set up a Next.js app from scratch (following the instructions of the [Vercel Edge Quickstart](https://vercel.com/docs/functions/edge-functions/quickstart)): + +```terminal +npm install -g vercel +npx create-next-app@latest +npm install prisma --save-dev +npx prisma init +``` + +We'll use the default `User` model for the example below: + +```prisma +model User { + id Int @id @default(autoincrement()) + email String @unique + name String? +} +``` + +### Vercel Postgres + +If you are using Vercel Postgres, you need to: + +- use the `@prisma/adapter-neon` database adapter (via the `driverAdapters` Preview feature) 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 + } + ``` + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "postgresql" + 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: + +```bash file=.env +POSTGRES_PRISMA_URL="postgres://user:password@host-pooler.region.postgres.vercel-storage.com:5432/name?pgbouncer=true&connect_timeout=15" +POSTGRES_URL_NON_POOLING="postgres://user:password@host.region.postgres.vercel-storage.com:5432/name" +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-neon +npm install @neondatabase/serverless +``` + +#### 3. Configure `postinstall` hook + +Next, add a new key to the `scripts` section in your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // ... + "postinstall": "prisma generate" + } +} +``` + +#### 4. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npx prisma migrate dev --name init +``` + +#### 5. Use Prisma Client in your Vercel Edge Function to send a query to the database + +If you created the project from scratch, you can create a new edge function as follows. + +First, create a new API route, e.g. by using these commands: + +```terminal +mkdir src/app/api +mkdir src/app/api/edge +touch src/app/api/edge/route.ts +``` + +Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database in the new `app/api/edge/route.ts` file you just created: + +```ts file=app/api/edge/route.ts +import { NextResponse } from 'next/server' +import { PrismaClient } from '@prisma/client' +import { PrismaNeon } from '@prisma/adapter-neon' +import { Pool } from '@neondatabase/serverless' + +export const runtime = 'edge' + +export async function GET(request: Request) { + const neon = new Pool({ connectionString: process.env.POSTGRES_PRISMA_URL }) + const adapter = new PrismaNeon(neon) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + + return NextResponse.json(users, { status: 200 }) +} +``` + +#### 6. Run the Edge Function locally + +Run the app with the following command: + +```terminal +npm run dev +``` + +You can now access the Edge Function via this URL: [`http://localhost:3000/api/edge`](http://localhost:3000/api/edge). + +#### 7. Set the `POSTGRES_PRISMA_URL` environment variable and deploy the Edge Function + +Run the following command to deploy your project with Vercel: + +```terminal +npx vercel deploy +``` + +Note that once the project was created on Vercel, you will need to set the `POSTGRES_PRISMA_URL` environment variable (and if this was your first deploy, it likely failed). You can do this either via the Vercel UI or by running the following command: + +``` +npx vercel env add POSTGRES_PRISMA_URL +``` + +At this point, you can get the URL of the deployed application from the Vercel Dashboard and access the edge function via the `/api/edge` route. + +### PlanetScale + +If you are using a PlanetScale database, you need to: + +- use the `@prisma/adapter-planetscale` database adapter (via the `driverAdapters` Preview feature) + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "mysql" + url = env("DATABASE_URL") + relationMode = "prisma" // required for PlanetScale (as by default foreign keys are disabled) +} +``` + +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 +DATABASE_URL="mysql://32qxa2r7hfl3102wrccj:password@us-east.connect.psdb.cloud/demo-cf-worker-ps?sslaccept=strict" +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-planetscale +npm install @planetscale/database +``` + +#### 3. Configure `postinstall` hook + +Next, add a new key to the `scripts` section in your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // ... + "postinstall": "prisma generate" + } +} +``` + +#### 4. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npx prisma db push +``` + +#### 5. Use Prisma Client in an Edge Function to send a query to the database + +If you created the project from scratch, you can create a new edge function as follows. + +First, create a new API route, e.g. by using these commands: + +```terminal +mkdir src/app/api +mkdir src/app/api/edge +touch src/app/api/edge/route.ts +``` + +Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database in the new `app/api/edge/route.ts` file you just created: + +```ts file=app/api/edge/route.ts +import { NextResponse } from 'next/server' +import { PrismaClient } from '@prisma/client' +import { PrismaPlanetScale } from '@prisma/adapter-planetscale' +import { Client } from '@planetscale/database' + +export const runtime = 'edge' + +export async function GET(request: Request) { + const client = new Client({ url: process.env.DATABASE_URL }) + const adapter = new PrismaPlanetScale(client) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + + return NextResponse.json(users, { status: 200 }) +} +``` + +#### 6. Run the Edge Function locally + +Run the app with the following command: + +```terminal +npm run dev +``` + +You can now access the Edge Function via this URL: [`http://localhost:3000/api/edge`](http://localhost:3000/api/edge). + +#### 7. Set the `DATABASE_URL` environment variable and deploy the Edge Function + +Run the following command to deploy your project with Vercel: + +```terminal +npx vercel deploy +``` + +Note that once the project was created on Vercel, you will need to set the `DATABASE_URL` environment variable (and if this was your first deploy, it likely failed). You can do this either via the Vercel UI or by running the following command: + +``` +npx vercel env add DATABASE_URL +``` + +At this point, you can get the URL of the deployed application from the Vercel Dashboard and access the edge function via the `/api/edge` route. + +### Neon + +If you are using a Neon database, you need to: + +- use the `@prisma/adapter-neon` database adapter (via the `driverAdapters` Preview feature) + +#### 1. Configure Prisma schema & database connection + +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. You also need to enable the `driverAdapters` feature flag: + +```prisma file=schema.prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["driverAdapters"] +} + +datasource db { + provider = "postgresql" + 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 +DATABASE_URL="postgresql://janedoe:password@ep-nameless-pond-a23b1mdz.eu-central-1.aws.neon.tech/neondb?sslmode=require" +``` + +#### 2. Install dependencies + +Next, install the required packages: + +```terminal +npm install @prisma/adapter-neon +npm install @neondatabase/serverless +``` + +#### 3. Configure `postinstall` hook + +Next, add a new key to the `scripts` section in your `package.json`: + +```js file=package.json highlight=5;add +{ + // ... + "scripts": { + // ... + "postinstall": "prisma generate" + } +} +``` + +#### 4. Migrate your database schema (if applicable) + +If you ran `npx prisma init` above, you need to migrate your database schema to create the `User` table that's defined in your Prisma schema (if you already have all the tables you need in your database, you can skip this step): + +```terminal +npx prisma migrate dev --name init +``` + +#### 5. Use Prisma Client in an Edge Function to send a query to the database + +If you created the project from scratch, you can create a new edge function as follows. + +First, create a new API route, e.g. by using these commands: + +```terminal +mkdir src/app/api +mkdir src/app/api/edge +touch src/app/api/edge/route.ts +``` + +Here is a sample code snippet that you can use to instantiate `PrismaClient` and send a query to your database in the new `app/api/edge/route.ts` file you just created: + +```ts file=app/api/edge/route.ts +import { NextResponse } from 'next/server' +import { PrismaClient } from '@prisma/client' +import { PrismaNeon } from '@prisma/adapter-neon' +import { Pool } from '@neondatabase/serverless' + +export const runtime = 'edge' + +export async function GET(request: Request) { + const neon = new Pool({ connectionString: process.env.DATABASE_URL }) + const adapter = new PrismaNeon(neon) + const prisma = new PrismaClient({ adapter }) + + const users = await prisma.user.findMany() + + return NextResponse.json(users, { status: 200 }) +} +``` + +#### 6. Run the Edge Function locally + +Run the app with the following command: + +```terminal +npm run dev +``` + +You can now access the Edge Function via this URL: [`http://localhost:3000/api/edge`](http://localhost:3000/api/edge). + +#### 7. Set the `DATABASE_URL` environment variable and deploy the Edge Function + +Run the following command to deploy your project with Vercel: + +```terminal +npx vercel deploy +``` + +Note that once the project was created on Vercel, you will need to set the `DATABASE_URL` environment variable (and if this was your first deploy, it likely failed). You can do this either via the Vercel UI or by running the following command: + +``` +npx vercel env add DATABASE_URL +``` + +At this point, you can get the URL of the deployed application from the Vercel Dashboard and access the edge function via the `/api/edge` route. 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 0341671a99..1cb8e1f9fd 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 @@ -6,13 +6,13 @@ metaDescription: 'Learn how to deploy a TypeScript application to Deno Deploy.' -With this guide, you can learn how to build and deploy a simple application to [Deno Deploy](https://deno.com/deploy). The application uses Prisma to save a log of each request to a PostgreSQL database. +With this guide, you can learn how to build and deploy a simple application to [Deno Deploy](https://deno.com/deploy). The application uses Prisma ORM to save a log of each request to a PostgreSQL database. This guide covers the use of Prisma CLI with Deno CLI, Deno Deploy, Prisma Client, and Prisma Accelerate. -This guide demonstrates how to deploy an application to Deno Deploy in conjunction with a PostgreSQL database, but you can use [any database type that Prisma supports](/orm/reference/supported-databases). +This guide demonstrates how to deploy an application to Deno Deploy in conjunction with a PostgreSQL database, but you can use [any database type that Prisma ORM supports](/orm/reference/supported-databases). @@ -102,7 +102,7 @@ deno run -A --unstable npm:prisma generate --no-engine -Prior to Prisma 5.2.0, the `--no-engine` flag is not available. Instead, use the `--accelerate` flag. +Prior to Prisma ORM 5.2.0, the `--no-engine` flag is not available. Instead, use the `--accelerate` flag. ```terminal deno run -A npm:prisma generate --accelerate @@ -187,7 +187,7 @@ To configure Prisma Accelerate: # DATABASE_URL="postgres://..." ``` -The configuration of your local environment is now ready to send Prisma queries to the database through Prisma Accelerate. +The configuration of your local environment is now ready to send Prisma Client queries to the database through Prisma Accelerate. ## 7. Test your application locally @@ -232,14 +232,6 @@ To set up a GitHub repository: git push -u origin main ``` - - -**Note**

- -Optionally, you can now also [link your GitHub repository to your project](/platform/classic-projects/platform/environments/create#projects-with-an-introspected-schema-or-with-no-schema) in the Prisma Data Platform so that you can keep it up-to-date with any changes you make in the `schema.prisma` file. - -
- ## 9. Deploy to Deno Deploy Use the GitHub repository to add your application to Deno Deploy: diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/index.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/index.mdx index 461d3d86b3..cb46530bec 100644 --- a/content/200-orm/200-prisma-client/500-deployment/301-edge/index.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/index.mdx @@ -1,16 +1,16 @@ --- title: 'Edge functions' -metaTitle: 'Deploy Prisma apps to edge function (distributed FaaS) providers' -metaDescription: 'Learn how to deploy your Prisma-backed apps to edge functions like Cloudflare Workers or Vercel Edge Functions' +metaTitle: 'Deploy Prisma ORM apps to edge function (distributed FaaS) providers' +metaDescription: 'Learn how to deploy your Prisma ORM-backed apps to edge functions like Cloudflare Workers or Vercel Edge Functions' tocDepth: 2 --- -If your application is deployed via an "Edge Function" offering or is deployed from a [serverless](/orm/prisma-client/deployment/serverless) offering and has a non-standard runtime, it is a edge deployed app. Common examples include [Cloudflare Workers](/orm/prisma-client/deployment/edge/deploy-to-cloudflare-workers), [Deno Deploy](/orm/prisma-client/deployment/edge/deploy-to-deno-deploy), and Vercel Edge Functions. +If your application is deployed via an "Edge Function" offering or is deployed from a [serverless](/orm/prisma-client/deployment/serverless) offering and has a non-standard runtime, it is a _edge-deployed_ app. Common examples for such offerings include [Cloudflare Workers or Pages](/orm/prisma-client/deployment/edge/deploy-to-cloudflare), [Vercel Edge Functions or Edge Middleware](/orm/prisma-client/deployment/edge/deploy-to-vercel), and [Deno Deploy](/orm/prisma-client/deployment/edge/deploy-to-deno-deploy). -## Guides for Edge Function providers +## In this section diff --git a/content/200-orm/200-prisma-client/500-deployment/400-module-bundlers.mdx b/content/200-orm/200-prisma-client/500-deployment/400-module-bundlers.mdx new file mode 100644 index 0000000000..509843fd10 --- /dev/null +++ b/content/200-orm/200-prisma-client/500-deployment/400-module-bundlers.mdx @@ -0,0 +1,19 @@ +--- +title: 'Module bundlers' +metaTitle: 'Module bundlers (Reference)' +metaDescription: 'This page gives an overview of the most important things to be aware of when using a module bundler to bundle an application that uses Prisma Client.' +--- + +## Overview + +_Module bundlers_ bundle JavaScript modules into a single JavaScript file. Most bundlers work by copying over the JavaScript code from a variety of source files into the target file. + +Since Prisma Client is not only based on JavaScript code, but also relies on the [**query engine binary file**](/orm/more/under-the-hood/engines#the-query-engine-file) to be available, you need to make sure that your bundled code has access to the binary file. + +To do so, you can use plugins that let you copy over static assets: + +| Bundler | Plugin | +| :---------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | +| Webpack | [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin#copy-webpack-plugin) | +| Webpack (with [Next.js monorepo](/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-monorepo)) | [`nextjs-monorepo-workaround-plugin`](https://www.npmjs.com/package/@prisma/nextjs-monorepo-workaround-plugin) | +| Parcel | [`parcel-plugin-static-files-copy`](https://github.com/elwin013/parcel-plugin-static-files-copy#readme) | 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 0bd45a44fd..d797f1a84d 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 @@ -15,7 +15,7 @@ npx prisma migrate deploy 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)). +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/200-prisma-client/500-deployment/650-caveats-when-deploying-to-aws-platforms.mdx b/content/200-orm/200-prisma-client/500-deployment/650-caveats-when-deploying-to-aws-platforms.mdx index d9f560e340..c1e0ae8944 100644 --- a/content/200-orm/200-prisma-client/500-deployment/650-caveats-when-deploying-to-aws-platforms.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/650-caveats-when-deploying-to-aws-platforms.mdx @@ -12,17 +12,17 @@ The following describes some caveats you might face when deploying to different ## AWS RDS Proxy -Prisma is compatible with AWS RDS Proxy. However, there is no benefit in using it for connection pooling with Prisma due to the way RDS Proxy pins connections: +Prisma ORM is compatible with AWS RDS Proxy. However, there is no benefit in using it for connection pooling with Prisma ORM due to the way RDS Proxy pins connections: > "Your connections to the proxy can enter a state known as pinning. When a connection is pinned, each later transaction uses the same underlying database connection until the session ends. Other client connections also can't reuse that database connection until the session ends. The session ends when Prisma Client's connection is dropped." - [AWS RDS Proxy Docs](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy-managing.html#rds-proxy-pinning) -[Prepared statements (of any size) or query statements greater than 16 KB cause RDS Proxy to pin the session.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-proxy-managing.html#rds-proxy-pinning.all) Because Prisma uses prepared statements for all queries, you won't see any benefit when using RDS Proxy with Prisma. +[Prepared statements (of any size) or query statements greater than 16 KB cause RDS Proxy to pin the session.](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-proxy-managing.html#rds-proxy-pinning.all) Because Prisma ORM uses prepared statements for all queries, you won't see any benefit when using RDS Proxy with Prisma ORM. ## AWS Elastic Beanstalk AWS Elastic Beanstalk is a PaaS-like deployment service that abstracts away infrastructure and allows you to deploy applications to AWS quickly. -When deploying an app using Prisma Client to AWS Elastic Beanstalk, Prisma generates the Prisma Client code into `node_modules`. This is typically done in the `postinstall` hook. +When deploying an app using Prisma Client to AWS Elastic Beanstalk, Prisma ORM generates the Prisma Client code into `node_modules`. This is typically done in the `postinstall` hook. Because Beanstalk limits the ability to write to the filesystem in the `postinstall` hook, you need to create an [`.npmrc`](https://docs.npmjs.com/cli/v6/configuring-npm/npmrc) file in the root of your project and add the following configuration: @@ -44,22 +44,24 @@ This error happens because AWS Elastic Beanstalk doesn't install `devDependencie AWS Lambda defines an **deployment package upload limit**, which includes: - All application code -- Binaries like the [Prisma query engine](/orm/more/under-the-hood/engines) +- Binaries like the [Prisma ORM query engine](/orm/more/under-the-hood/engines) -The [deployment package (.zip) size limit for lambdas is 50MB](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html). When you prepare a deployment package, remove any files that the function does not require in production to keep the final .zip as small as possible. This includes some [Prisma engine binaries](#deleting-prisma-engines-that-are-not-required). +The [deployment package (.zip) size limit for lambdas is 50MB](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html). When you prepare a deployment package, remove any files that the function does not require in production to keep the final .zip as small as possible. This includes some [Prisma ORM engine binaries](#deleting-prisma-orm-engines-that-are-not-required). -### Deleting Prisma engines that are not required +### Deleting Prisma ORM engines that are not required Prisma CLI downloads additional engine binaries that are **not required** in production. You can delete the following files and folders: 1. The entire `node_modules/@prisma/engines` folder (refer to the [sample bash script](https://github.com/prisma/ecosystem-tests/blob/13e74dc47eababa5d3c8f488b73fe7fc8bffead7/platforms-serverless/lambda/run.sh#L16) used by the Prisma end-to-end tests) -2. The **local engine file** for your development platform from the `node_modules/.prisma/client` folder. For example, your schema might define the following `binaryTargets` if you develop on Debian (`native`) but deploy to AWS Lambda (`rhel-openssl-1.0.x`): +2. The **local engine file** for your development platform from the `node_modules/.prisma/client` folder. For example, your schema might define the following `binaryTargets` if you develop on Debian (`native`) but deploy to AWS Lambda (`rhel-openssl-3.0.x`): ```prisma - binaryTargets = ["native", "rhel-openssl-1.0.x"] + binaryTargets = ["native", "rhel-openssl-3.0.x"] ``` In this scenario: - - Keep `node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x`, which is the engine file used by AWS Lambda + - Keep `node_modules/.prisma/client/query-engine-rhel-openssl-3.0.x`, which is the engine file used by AWS Lambda - Delete `node_modules/.prisma/client/query-engine-debian-openssl-1.1.x`, which is only required locally + + > **Note**: When using Node.js 18 or earlier, the correct `binaryTarget` for AWS Lambda is `rhel-openssl-1.0.x`. `rhel-openssl-3.0.x` is the correct `binaryTarget` for Node.js versions greater than 18. diff --git a/content/200-orm/200-prisma-client/500-deployment/700-deploy-to-a-different-os.mdx b/content/200-orm/200-prisma-client/500-deployment/700-deploy-to-a-different-os.mdx index a1dd19f9be..3a19139e38 100644 --- a/content/200-orm/200-prisma-client/500-deployment/700-deploy-to-a-different-os.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/700-deploy-to-a-different-os.mdx @@ -8,7 +8,7 @@ metaDescription: 'Learn how to deploy Node.js and TypeScript applications that a Prisma Client depends on the [query engine](/orm/more/under-the-hood/engines) that is running as a binary on the same host as your application. -The query engine is implemented in Rust and is used by Prisma in the form of executable binary files. The binary is downloaded when `prisma generate` is called. +The query engine is implemented in Rust and is used by Prisma Client in the form of executable binary files. The binary is downloaded when `prisma generate` is called. If you have developed your application on a Windows machine for example, and wish to upload to AWS Lambda, which is a Linux environment, you may encounter issues and be presented with some warnings in your terminal. 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 60fd05dd0d..5b68439fca 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 @@ -8,7 +8,7 @@ metaDescription: 'Learn how to configure Prisma Client to log the raw SQL querie Use the `PrismaClient` [`log`](/orm/reference/prisma-client-reference#log) parameter to configure [log levels](/orm/reference/prisma-client-reference#log-levels) , including warnings, errors, and information about the queries sent to the database. -Prisma supports two types of logging: +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)) 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 e805599be7..ad28441bbd 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 @@ -8,7 +8,7 @@ tocDepth: 4 -Prisma metrics give you a detailed insight into how Prisma Client interacts with your database. You can use this insight to help diagnose performance issues with your application. +Prisma Client metrics give you a detailed insight into how Prisma Client interacts with your database. You can use this insight to help diagnose performance issues with your application. @@ -50,12 +50,12 @@ You can [add global labels to your metrics data](#global-labels) to help you gro ## Prerequisites -To use Prisma metrics, you must do the following: +To use Prisma Client metrics, you must do the following: -1. [Install the appropriate dependencies](#step-1-install-up-to-date-prisma-dependencies). +1. [Install the appropriate dependencies](#step-1-install-up-to-date-prisma-orm-dependencies). 1. [Enable the `metrics` feature flag in your Prisma schema file](#step-2-enable-the-feature-flag-in-the-prisma-schema-file). -### Step 1. Install up-to-date Prisma dependencies +### Step 1. Install up-to-date Prisma ORM dependencies Use version `3.15.0` or higher of the `prisma` and `@prisma/client` npm packages. @@ -77,7 +77,7 @@ generator client { ## Retrieve metrics in JSON format -When you retrieve metrics in JSON format, you can use them in the format they are returned, or [send them to StatSD](#use-prisma-metrics-with-statsd) to visualize how they change over time. +When you retrieve metrics in JSON format, you can use them in the format they are returned, or [send them to StatSD](#use-prisma-client-metrics-with-statsd) to visualize how they change over time. To retrieve metrics in JSON format, add the following lines to your application code: @@ -265,13 +265,13 @@ Each histogram "bucket" has two values. The first one is the upper bound of the ... ``` -### Use Prisma metrics with StatsD +### Use Prisma Client metrics with StatsD You can send JSON-formatted metrics to [StatsD](https://github.com/statsd/statsd) to visualize your metrics data over time. -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 counter +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`. @@ -338,7 +338,7 @@ setInterval(async () => await statsdSender(), 10000) ## Retrieve metrics in Prometheus format -When you retrieve Prisma metrics in Prometheus format, you can use them in the format they are returned, or [send them to the Prometheus metrics system](#use-prisma-metrics-with-the-prometheus-metrics-system) to visualize how they change over time. +When you retrieve Prisma Client metrics in Prometheus format, you can use them in the format they are returned, or [send them to the Prometheus metrics system](#use-prisma-client-metrics-with-the-prometheus-metrics-system) to visualize how they change over time. To retrieve metrics in Prometheus format, add the following lines to your application code: @@ -465,14 +465,14 @@ Metrics of type `histogram` expose three different class of values in the Promet 1. Multiple cumulative counters for observation buckets. These counters are suffixed with `_bucket{le=""}`. For example, `prisma_datasource_queries_duration_histogram_ms` has a counter exposed as `prisma_datasource_queries_duration_histogram_ms_bucket{le="1"}` - When an observed value is less than or equal to the upper inclusive bound of a bucket, then Prisma Metrics increments that bucket by 1. Suppose that you have buckets with the upper inclusive bounds 0, 1, 5, 10, and 50 respectively. If the observed value is 5 then Prisma Metrics increments the third bucket onwards, because the value is greater than 0 and greater than 1, but less than or equal to 5, 10, and 50. + When an observed value is less than or equal to the upper inclusive bound of a bucket, then Prisma Client metrics increments that bucket by 1. Suppose that you have buckets with the upper inclusive bounds 0, 1, 5, 10, and 50 respectively. If the observed value is 5 then Prisma Client metrics increments the third bucket onwards, because the value is greater than 0 and greater than 1, but less than or equal to 5, 10, and 50. 2. A single **total sum** for all observed values. This counter is suffixed with `_sum`. For example the total sum of `prisma_datasource_queries_duration_histogram_ms` is exposed as `prisma_datasource_queries_duration_histogram_ms_sum`. 3. The **count** of the number of events that have been observed. This counter is suffixed with `_count`. For example the total count of `prisma_datasource_queries_duration_histogram_ms` events is exposed as `prisma_datasource_queries_duration_histogram_ms_count`. For more information, read the Prometheus documentation on [metric types](https://prometheus.io/docs/concepts/metric_types/#histogram). -### Use Prisma metrics with the Prometheus metrics system +### Use Prisma Client metrics with the Prometheus metrics system In the majority of cases, Prometheus must scrape an endpoint to retrieve metrics. The following example shows how to send data with `Express.js`: @@ -494,7 +494,7 @@ app.listen(port, () => { }) ``` -The following example shows how to combine Prisma metrics with other Prometheus client libraries that are also served with a REST API endpoint in conjunction with `Express.js`: +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' 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 0c06f8d2b2..01ec55712f 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 @@ -12,7 +12,7 @@ Tracing provides a detailed log of the activity that Prisma Client carries out, -Tracing gives you a highly detailed, operation-level insight into your Prisma project. If you want aggregated numerical reporting, such as query counts, connection counts, and total query execution times, see [Metrics](/orm/prisma-client/observability-and-logging/metrics). +Tracing gives you a highly detailed, operation-level insight into your Prisma ORM project. If you want aggregated numerical reporting, such as query counts, connection counts, and total query execution times, see [Metrics](/orm/prisma-client/observability-and-logging/metrics). @@ -35,11 +35,11 @@ You can [send tracing output to the console](#send-tracing-output-to-the-console ## Trace output -For each trace, Prisma Client outputs a series of spans. The number and type of these spans depends on the Prisma operation. A typical Prisma trace has the following spans: +For each trace, Prisma Client outputs a series of spans. The number and type of these spans depends on the Prisma Client operation. A typical Prisma trace has the following spans: -- `prisma:client:operation`: Represents the entire Prisma operation, from Prisma Client to the database and back. It contains details such as the model and method called by Prisma Client. Depending on the Prisma operation, it contains one or more of the following spans: +- `prisma:client:operation`: Represents the entire Prisma Client operation, from Prisma Client to the database and back. It contains details such as the model and method called by Prisma Client. Depending on the Prisma operation, it contains one or more of the following spans: - `prisma:client:connect`: Represents how long it takes for Prisma Client to connect to the database. - - `prisma:client:serialize`: Represents how long it takes to validate and transform a Prisma operation into a query for the [query engine](/orm/more/under-the-hood/engines). + - `prisma:client:serialize`: Represents how long it takes to validate and transform a Prisma Client operation into a query for the [query engine](/orm/more/under-the-hood/engines). - `prisma:engine`: Represents how long a query takes in the query engine. - `prisma:engine:connection`: Represents how long it takes for Prisma Client to get a database connection. - `prisma:engine:db_query`: Represents the database query that was executed against the database. It includes the query in the tags, and how long the query took to run. @@ -74,15 +74,15 @@ If your application sends a large number of spans to a [collector](https://opent To use tracing, you must do the following: -1. [Install the appropriate dependencies](#step-1-install-up-to-date-prisma-dependencies). +1. [Install the appropriate dependencies](#step-1-install-up-to-date-prisma-orm-dependencies). 1. [Enable the `tracing` feature flag in your Prisma schema file](#step-2-enable-the-feature-flag-in-your-prisma-schema-file). 1. [Install OpenTelemetry packages](#step-3-install-opentelemetry-packages). -## Get started with tracing in Prisma +## Get started with tracing in Prisma ORM This section explains how to install and register tracing in your application. -### Step 1. Install up-to-date Prisma dependencies +### Step 1. Install up-to-date Prisma ORM dependencies Use version `4.2.0` or later of the `prisma`, `@prisma/client`, and `@prisma/instrumentation` npm packages. diff --git a/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/140-debugging.mdx b/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/140-debugging.mdx index 30be2c7216..e92f8c1241 100644 --- a/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/140-debugging.mdx +++ b/content/200-orm/200-prisma-client/700-debugging-and-troubleshooting/140-debugging.mdx @@ -8,7 +8,7 @@ metaDescription: 'This page explains how to enable debugging output for Prisma C You can enable debugging output in Prisma Client via the [`DEBUG`](/orm/reference/environment-variables-reference#debug) environment variable. It accepts two namespaces to print debugging output: -- `prisma:engine`: Prints relevant debug messages happening in a Prisma [engine](https://github.com/prisma/prisma-engines/) +- `prisma:engine`: Prints relevant debug messages happening in a Prisma ORM [engine](https://github.com/prisma/prisma-engines/) - `prisma:client`: Prints relevant debug messages happening in the Prisma Client runtime - `prisma*`: Prints all debug messages from Prisma Client or CLI - `*`: Prints all debug messages diff --git a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/070-migration-histories.mdx b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/070-migration-histories.mdx index b6fe72d92a..3a5f210960 100644 --- a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/070-migration-histories.mdx +++ b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/070-migration-histories.mdx @@ -7,7 +7,7 @@ tocDepth: 3 -This page explains how Prisma uses migration histories to track changes to your schema. +This page explains how Prisma ORM uses migration histories to track changes to your schema. 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 26fad023f3..e682866a9b 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 @@ -113,7 +113,7 @@ In order to create and delete the shadow database when using `migrate dev`, Pris | Database | Database user requirements | | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | SQLite | No special requirements. | -| MySQL | Database user must have `CREATE, ALTER, DROP, REFERENCES ON *.*` privileges | +| MySQL/MariaDB | Database user must have `CREATE, ALTER, DROP, REFERENCES ON *.*` privileges | | PostgreSQL | The user must be a super user or have `CREATEDB` privilege. See `CREATE ROLE` ([PostgreSQL official documentation](https://www.postgresql.org/docs/12/sql-createrole.html)) | | Microsoft SQL Server | The user must be a site admin or have the `SERVER` securable. See the [official documentation](https://docs.microsoft.com/en-us/sql/relational-databases/security/permissions-database-engine?view=sql-server-ver15). | @@ -133,6 +133,6 @@ To resolve this error: - If you are working locally, we recommend that you update the database user's privileges. - If you are developing against a database that does not allow creating and dropping databases (for any reason) see [Manually configuring the shadow database](#manually-configuring-the-shadow-database) - If you are developing against a cloud-based database (for example, on Heroku, Digital Ocean, or Vercel Postgres) see: [Cloud-hosted shadow databases](#cloud-hosted-shadow-databases-must-be-created-manually). -- If you are developing against a cloud-based database (for example, on Heroku, Digital Ocean, or Vercel Postgres) and are currently **prototyping** such that you don't care about generated migration files and only need to apply your Prisma data model to the database schema, you can run [`prisma db push`](/orm/reference/prisma-cli-reference#db) instead of the `prisma migrate dev` command. +- If you are developing against a cloud-based database (for example, on Heroku, Digital Ocean, or Vercel Postgres) and are currently **prototyping** such that you don't care about generated migration files and only need to apply your Prisma schema to the database schema, you can run [`prisma db push`](/orm/reference/prisma-cli-reference#db) instead of the `prisma migrate dev` command. > **Important**: The shadow database is _only_ required in a development environment (specifically for the `prisma migrate dev` command) - you **do not** need to make any changes to your production environment. diff --git a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/300-limitations-and-known-issues.mdx b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/300-limitations-and-known-issues.mdx index 4e9dffeab1..49be07a481 100644 --- a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/300-limitations-and-known-issues.mdx +++ b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/300-limitations-and-known-issues.mdx @@ -63,7 +63,7 @@ See [Prisma Migrate and PgBouncer workaround](/orm/prisma-client/setup-and-confi ## Prisma Migrate in non-interactive environments -Prisma detects when you run CLI commands in non-interactive environments, such as Docker, from Node scripts or in bash shells. When this happens a warning displays, indicating that the environment is non-interactive and the `migrate dev` command is not supported. +Prisma ORM detects when you run CLI commands in non-interactive environments, such as Docker, from Node scripts or in bash shells. When this happens a warning displays, indicating that the environment is non-interactive and the `migrate dev` command is not supported. To ensure the Docker environment picks up the command, run the image in `interactive` mode so that it reacts to the `migrate dev` command. diff --git a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/600-legacy-migrate.mdx b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/600-legacy-migrate.mdx index 88bd326fad..d2620d34bc 100644 --- a/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/600-legacy-migrate.mdx +++ b/content/200-orm/300-prisma-migrate/200-understanding-prisma-migrate/600-legacy-migrate.mdx @@ -25,7 +25,7 @@ If you want to prototype or iterate on a schema design in a development environm Legacy Prisma Migrate is a _declarative_ migration system, as opposed to SQL which can be considered _imperative_: - **SQL (imperative)**: Provide the individual _steps_ to get from the current schema to the desired schema. -- **legacy Prisma Migrate (declarative)**: Define the desired schema as a [Prisma data model](/orm/prisma-schema/data-model/models) (legacy Prisma Migrate takes care of generating the necessary _steps_). +- **legacy Prisma Migrate (declarative)**: Define the desired schema as a [Prisma schema data model](/orm/prisma-schema/data-model/models) (legacy Prisma Migrate takes care of generating the necessary _steps_). Here's a quick comparison. Assume you have the following scenario: @@ -73,7 +73,7 @@ ADD COLUMN published BOOLEAN DEFAULT false; #### legacy Prisma Migrate -With legacy Prisma Migrate, you write the desired database schema in the form of a [Prisma data model](/orm/prisma-schema/data-model/models) inside your [Prisma schema file](/orm/prisma-schema). To map the data model to your database schema, you then have to run these two commands: +With legacy Prisma Migrate, you write the desired database schema in the form of a [Prisma schema data model](/orm/prisma-schema/data-model/models) inside your [Prisma schema file](/orm/prisma-schema). To map the data model to your database schema, you then have to run these two commands: ```terminal prisma migrate save --experimental @@ -222,7 +222,7 @@ The `_Migration` table additionally stores information about each migration that With **legacy Prisma Migrate**, the workflow looks slightly different: -1. Manually adjust your [Prisma data model](/orm/prisma-schema/data-model/models) +1. Manually adjust your [Prisma schema data model](/orm/prisma-schema/data-model/models) 1. Migrate your database using the `legacy Prisma Migrate` CLI commands 1. (Re-)generate Prisma Client 1. Use Prisma Client in your application code to access your database 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 4f0a047239..d4e3b9a2a3 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 @@ -1,22 +1,22 @@ --- title: Seeding metaTitle: Seeding -metaDescription: Learn how to seed your database using Prisma's integrated seeding functionality and Prisma Client +metaDescription: Learn how to seed your database using Prisma ORM's integrated seeding functionality and Prisma Client tocDepth: 3 --- -This guide describes how to seed your database using Prisma Client and Prisma's integrated seeding functionality. Seeding allows you to consistently re-create the same data in your database and can be used to: +This guide describes how to seed your database using Prisma Client and Prisma ORM's integrated seeding functionality. Seeding allows you to consistently re-create the same data in your database and can be used to: - Populate your database with data that is required for your application to start - for example, a default language or a default currency. - Provide basic data for validating and using your application in a development environment. This is particularly useful if you are using Prisma Migrate, which sometimes requires resetting your development database. -## How to seed your database in Prisma +## How to seed your database in Prisma ORM -Prisma's integrated seeding functionality expects a command in the `"seed"` key in the `"prisma"` key of your `package.json` file. This can be any command, `prisma db seed` will just execute it. In this guide and as a default, we recommend writing a seed script inside your project's `prisma/` folder and starting it with the command. +Prisma ORM's integrated seeding functionality expects a command in the `"seed"` key in the `"prisma"` key of your `package.json` file. This can be any command, `prisma db seed` will just execute it. In this guide and as a default, we recommend writing a seed script inside your project's `prisma/` folder and starting it with the command. , ]}> @@ -55,7 +55,7 @@ This can be useful to reduce memory usage (RAM) and increase execution speed of ## Integrated seeding with Prisma Migrate -Database seeding happens in two ways with Prisma: manually with `prisma db seed` and automatically in `prisma migrate dev` and `prisma migrate reset`. +Database seeding happens in two ways with Prisma ORM: manually with `prisma db seed` and automatically in `prisma migrate dev` and `prisma migrate reset`. With `prisma db seed`, _you_ decide when to invoke the seed command. It can be useful for a test setup or to prepare a new development environment, for example. @@ -395,7 +395,7 @@ npx prisma db seed -- --environment development ## Going further -Here's a non-exhaustive list of other tools you can integrate with Prisma in your development workflow to seed your database: +Here's a non-exhaustive list of other tools you can integrate with Prisma ORM in your development workflow to seed your database: - [Replibyte](https://www.replibyte.com/docs/introduction) - [Snaplet](https://docs.snaplet.dev/recipes/prisma) 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 777345b13b..0a18c0ca1d 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 @@ -21,7 +21,7 @@ Prisma Migrate also supports mapping each field to a [specific native type](#map -¹ Comments and Prisma-level functions (`uuid()` and `cuid()`) do not map to database features. +¹ Comments and Prisma ORM-level functions (`uuid()` and `cuid()`) do not map to database features. @@ -29,11 +29,11 @@ Prisma Migrate also supports mapping each field to a [specific native type](#map ## Mapping fields to a specific native type -Each Prisma 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. +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. -**Note**: Some Prisma types only map to a single native type. +**Note**: Some Prisma ORM types only map to a single native type. @@ -82,9 +82,9 @@ CREATE TABLE "Post" ( ALTER TABLE "Post" ADD FOREIGN KEY("authorId")REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; ``` -### Mappings by Prisma type +### Mappings by Prisma ORM type -For type mappings organized by Prisma type, refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) documentation. +For type mappings organized by Prisma ORM type, refer to the [Prisma schema reference](/orm/reference/prisma-schema-reference#model-field-scalar-types) documentation. ### Mappings by database provider 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 b310d48ae2..461e1eba17 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 @@ -16,7 +16,7 @@ Do not activate extensions outside a migration file if you use Prisma Migrate. T -In Prisma 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): +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 generator client { @@ -33,7 +33,7 @@ datasource db { You can then apply these changes to your database with Prisma Migrate. See [How to migrate PostgreSQL extensions](/orm/prisma-schema/postgresql-extensions#how-to-migrate-postgresql-extensions) for details. -In earlier versions of Prisma, you must instead add a SQL command to your migration file to activate the extension. See [How to install a PostgreSQL extension as part of a migration](#how-to-install-a-postgresql-extension-as-part-of-a-migration). +In earlier versions of Prisma ORM, you must instead add a SQL command to your migration file to activate the extension. See [How to install a PostgreSQL extension as part of a migration](#how-to-install-a-postgresql-extension-as-part-of-a-migration). diff --git a/content/200-orm/300-prisma-migrate/300-workflows/45-data-migration.mdx b/content/200-orm/300-prisma-migrate/300-workflows/45-data-migration.mdx index 5640babf88..8d7a194e53 100644 --- a/content/200-orm/300-prisma-migrate/300-workflows/45-data-migration.mdx +++ b/content/200-orm/300-prisma-migrate/300-workflows/45-data-migration.mdx @@ -1,14 +1,14 @@ --- title: Data migrations -metaDescription: How to migrate data using Prisma using the expand and contract pattern. +metaDescription: How to migrate data using Prisma ORM with the expand and contract pattern. tocDepth: 3 --- -Prisma does not yet natively support data migrations, but you can use the [expand and contract pattern](https://www.prisma.io/dataguide/types/relational/expand-and-contract-pattern) to migrate your data. For example from one column into another. +Prisma ORM does not yet natively support data migrations, but you can use the [expand and contract pattern](https://www.prisma.io/dataguide/types/relational/expand-and-contract-pattern) to migrate your data. For example from one column into another. -This guide covers how you can use Prisma with the expand and contract pattern to: +This guide covers how you can use Prisma ORM with the expand and contract pattern to: - Expand your schema with a new column - Create and run the data migration 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 98dd67e26f..e940ee37db 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 @@ -124,7 +124,7 @@ The following example demonstrates how to manually complete the steps of a migra ## Fixing failed migrations with migrate diff and db execute -To help with fixing a failed migration, Prisma provides the following commands for creating and executing a migration file: +To help with fixing a failed migration, Prisma ORM provides the following commands for creating and executing a migration file: - [`prisma migrate diff`](/orm/reference/prisma-cli-reference#migrate-diff) which diffs two database schema sources to create a migration taking one to the state of the second. You can output either a summary of the difference or a sql script. The script can be output into a file via `> file_name.sql` or be piped to the `db execute --stdin` command. - [`prisma db execute`](/orm/reference/prisma-cli-reference#db-execute) which applies a SQL script to the database without interacting with the Prisma migrations table. diff --git a/content/200-orm/400-tools/05-prisma-cli.mdx b/content/200-orm/400-tools/05-prisma-cli.mdx index 7010a28f38..3e9051a1af 100644 --- a/content/200-orm/400-tools/05-prisma-cli.mdx +++ b/content/200-orm/400-tools/05-prisma-cli.mdx @@ -192,7 +192,7 @@ All `prisma` CLI commands return the following codes when they exit: - exit code 0 when a command runs successfully - exit code 1 when a command errors -- exit code 130 when the CLI receives a signal interrupt (SIGINT) message or if the user cancels a prompt. This exit code is available in Prisma versions 4.3.0 and later. +- exit code 130 when the CLI receives a signal interrupt (SIGINT) message or if the user cancels a prompt. This exit code is available in Prisma ORM versions 4.3.0 and later. ## Telemetry 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 267745c32b..f8b429bb2a 100644 --- a/content/200-orm/500-reference/050-prisma-client-reference.mdx +++ b/content/200-orm/500-reference/050-prisma-client-reference.mdx @@ -332,7 +332,7 @@ main() ### errorFormat -Determines the level and formatting of errors returned by Prisma. +Determines the level and formatting of errors returned by Prisma Client. #### Error formats @@ -389,7 +389,7 @@ This is available from version 5.4.0 and newer behind the `driverAdapters` featu #### Example -The example below uses the [Neon driver adapter](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-preview) +The example below uses the [Neon driver adapter](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm-preview) ```ts import { Pool, neonConfig } from '@neondatabase/serverless' @@ -467,6 +467,40 @@ const prisma = new PrismaClient({ }) ``` +### transactionOptions + + + +**Note**: `transactionOptions` was introduced in v5.10.0. + + + +Allows to set [transaction options](/orm/prisma-client/queries/transactions#transaction-options) globally on the constructor level. + +#### Remarks + +- The transaction levels can be overridden on a per-transaction level. + +#### Options + +| Option | Description | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `maxWait` | The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds. | +| `timeout` | The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds. | +| `isolationLevel` | Sets the [transaction isolation level](/orm/prisma-client/queries/transactions#transaction-isolation-level). By default this is set to the value currently configured in your database. The available can vary depending on the database you use. | + +#### Example + +```ts +const prisma = new PrismaClient({ + transactionOptions: { + isolationLevel: Prisma.TransactionIsolationLevel.Serializable, + maxWait: 5000, // default: 2000 + timeout: 10000, // default: 5000 + }, +}) +``` + ## Model queries Use model queries to perform CRUD operations on your models. See also: [CRUD](/orm/prisma-client/queries/crud) @@ -482,18 +516,19 @@ Use model queries to perform CRUD operations on your models. See also: [CRUD](/o #### Remarks -- Prisma's dataloader [automatically batches `findUnique` queries](/orm/prisma-client/queries/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prismas-dataloader) with the same `select` and `where` parameters. +- Prisma Client's dataloader [automatically batches `findUnique` queries](/orm/prisma-client/queries/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prisma-clients-dataloader) with the same `select` and `where` parameters. - If you want the query to throw an error if the record is not found, then consider using [`findUniqueOrThrow`](#finduniqueorthrow) instead. - You cannot use [filter conditions](#filter-conditions-and-operators) (e.g. `equals`, `contains`, `not`) to filter fields of the [JSON](/orm/reference/prisma-schema-reference#json) data type. Using filter conditions will likely result in a `null` response for that field. #### Options -| Name | Example type (`User`) | Required | Description | -| ------------------------------- | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | -| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | -| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound`is deprecated in v4.0.0. From v4.0.0, use [`findUniqueOrThrow`](#finduniqueorthrow) instead. | +| Name | Example type (`User`) | Required | Description | +| ------------------------------- | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | +| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | +| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound`is deprecated in v4.0.0. From v4.0.0, use [`findUniqueOrThrow`](#finduniqueorthrow) instead. | #### Return type @@ -611,17 +646,18 @@ We introduced `findUniqueOrThrow` in v4.0.0. It replaces the [`rejectOnNotFound` #### Options -| Name | Example type (`User`) | Required | Description | -| ------------------------------- | ------------------------------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | -| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | -| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | -| `orderBy` | `XOR`OrderByInput>,UserOrderByInput>` | No | Lets you order the returned list by any property. | -| `cursor` | `UserWhereUniqueInput` | No | Specifies the position for the list (the value typically specifies an `id` or another unique value). | -| `take` | `number` | No | Specifies how many objects should be returned in the list. When used with `findFirst`, `take` is implicitly `1` or `-1`. `findFirst` is only affected by whether the value is positive or negative - any negative value reverses the list. | -| `skip` | `number` | No | Specifies how many of the returned objects in the list should be skipped. | -| `distinct` | `Enumerable`FieldEnum>` | No | Lets you filter out duplicate rows by a specific field - for example, return only distinct `Post` titles. | -| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound`is deprecated in v4.0.0. From v4.0.0, use [`findFirstOrThrow`](#findfirstorthrow) instead. | | +| Name | Example type (`User`) | Required | Description | +| ------------------------------- | ------------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | +| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | +| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | +| `orderBy` | `XOR`OrderByInput>,UserOrderByInput>` | No | Lets you order the returned list by any property. | +| `cursor` | `UserWhereUniqueInput` | No | Specifies the position for the list (the value typically specifies an `id` or another unique value). | +| `take` | `number` | No | Specifies how many objects should be returned in the list. When used with `findFirst`, `take` is implicitly `1` or `-1`. `findFirst` is only affected by whether the value is positive or negative - any negative value reverses the list. | +| `skip` | `number` | No | Specifies how many of the returned objects in the list should be skipped. | +| `distinct` | `Enumerable`FieldEnum>` | No | Lets you filter out duplicate rows by a specific field - for example, return only distinct `Post` titles. | +| `rejectOnNotFound` (deprecated) | `RejectOnNotFound` | No | If true, throw a `NotFoundError: No User found error`. You can also [configure `rejectOnNotFound` globally](#rejectonnotfound).

**Note:** `rejectOnNotFound`is deprecated in v4.0.0. From v4.0.0, use [`findFirstOrThrow`](#findfirstorthrow) instead. | | #### Return type @@ -717,16 +753,17 @@ We introduced `findFirstOrThrow` in v4.0.0. It replaces the [`rejectOnNotFound`] #### Options -| Name | Type | Required | Description | -| ---------- | ------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | -| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | -| `orderBy` | `XOR`ByInput>, PostOrderByInput>` | No | Lets you order the returned list by any property. | -| `cursor` | `UserWhereUniqueInput` | No | Specifies the position for the list (the value typically specifies an `id` or another unique value). | -| `take` | `number` | No | Specifies how many objects should be returned in the list (as seen from the _beginning_ (positive value) or _end_ (negative value) **either** of the list **or** from the `cursor` position if mentioned) | -| `skip` | `number` | No | Specifies how many of the returned objects in the list should be skipped. | -| `distinct` | `Enumerable` | No | Lets you filter out duplicate rows by a specific field - for example, return only distinct `Post` titles. | +| Name | Type | Required | Description | +| ---------------------- | ------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `select` | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| `include` | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | +| `where` | `UserWhereInput` | No | Wraps _all_ model fields in a type so that the list can be filtered by any property. | +| `orderBy` | `XOR`ByInput>, PostOrderByInput>` | No | Lets you order the returned list by any property. | +| `cursor` | `UserWhereUniqueInput` | No | Specifies the position for the list (the value typically specifies an `id` or another unique value). | +| `take` | `number` | No | Specifies how many objects should be returned in the list (as seen from the _beginning_ (positive value) or _end_ (negative value) **either** of the list **or** from the `cursor` position if mentioned) | +| `skip` | `number` | No | Specifies how many of the returned objects in the list should be skipped. | +| `distinct` | `Enumerable` | No | Lets you filter out duplicate rows by a specific field - for example, return only distinct `Post` titles. | #### Return type @@ -754,11 +791,13 @@ const user = await prisma.user.findMany({ #### Options -| Name | Type | Required | Description | -| --------------------- | -------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | `XOR`UserUncheckedCreateInput>` | **Yes** | Wraps all the model fields in a type so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional. | -| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| Name | Type | Required | Description | +| ---------------------- | -------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `data` | `XOR`UserUncheckedCreateInput>` | **Yes** | Wraps all the model fields in a type so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional. | +| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | +| | #### Return type @@ -858,12 +897,13 @@ prisma:query COMMIT #### Options -| Name | Type | Required | Description | -| --------------------- | ------------------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | `XOR`UserUncheckedUpdateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional. | -| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | -| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| Name | Type | Required | Description | +| ---------------------- | ------------------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `data` | `XOR`UserUncheckedUpdateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional. | +| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | +| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | #### Return type @@ -891,6 +931,12 @@ const user = await prisma.user.update({ ### upsert() + + +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: - If an existing database record satisfies the `where` condition, it updates that record @@ -898,13 +944,14 @@ const user = await prisma.user.update({ #### Options -| Name | Type | Required | Description | -| --------------------- | ------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `create` | `XOR`UserUncheckedCreateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional. | -| `update` | `XOR`UserUncheckedUpdateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional. | -| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | -| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| Name | Type | Required | Description | +| ---------------------- | ------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `create` | `XOR`UserUncheckedCreateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional. | +| `update` | `XOR`UserUncheckedUpdateInput>` | **Yes** | Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional. | +| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | +| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | #### Return type @@ -917,7 +964,7 @@ const user = await prisma.user.update({ - To perform arithmetic operations on update (add, subtract, multiply, divide), use [atomic updates](#atomic-number-operations) to prevent race conditions. - If two or more upsert operations happen at the same time and the record doesn't already exist, then a race condition might happen. As a result, one or more of the upsert operations might throw a unique key constraint error. Your application code can catch this error and retry the operation. [Learn more](#unique-key-constraint-errors-on-upserts). -- From version 4.6.0, Prisma hands over upsert queries to the database where possible. [Learn more](#database-upserts). +- From version 4.6.0, Prisma ORM hands over upsert queries to the database where possible. [Learn more](#database-upserts). #### Examples @@ -939,10 +986,10 @@ If multiple upsert operations happen at the same time and the record doesn't alr ##### Cause -When Prisma does an upsert, it first checks whether that record already exists in the database. To make this check, Prisma performs a read operation with the `where` clause from the upsert operation. This has two possible outcomes, as follows: +When Prisma Client does an upsert, it first checks whether that record already exists in the database. To make this check, Prisma Client performs a read operation with the `where` clause from the upsert operation. This has two possible outcomes, as follows: -- If the record does not exist, then Prisma creates that record. -- If the record exists, then Prisma updates it. +- If the record does not exist, then Prisma Client creates that record. +- If the record exists, then Prisma Client updates it. When your application tries to perform two or more concurrent upsert operations, then a race condition might happen where two or more operations do not find the record and therefore try to create that record. In this situation, one of the operations successfully creates the new record but the other operations fail and return a unique key constraint error. @@ -956,7 +1003,7 @@ Where possible, Prisma Client hands over an `upsert` query to the database. This Database upserts have the following advantages: -- They are faster than upserts handled by Prisma +- They are faster than upserts handled by Prisma Client - [Unique key constraint errors](#unique-key-constraint-errors-on-upserts) cannot happen Prisma Client uses a database upsert automatically when [specific criteria](#database-upsert-query-criteria) are met. When these criteria are not met, Prisma Client handles the `upsert`. @@ -967,7 +1014,7 @@ To use a database upsert, Prisma Client sends the SQL construction [`INSERT ... Prisma Client can use database upserts if your stack meets the following criteria: -- You use Prisma version 4.6.0 or later +- You use Prisma ORM version 4.6.0 or later - Your application uses a CockroachDB, PostgreSQL, or SQLite data source ##### Database upsert query criteria @@ -1104,11 +1151,12 @@ To delete records that match a certain criteria, use [`deleteMany`](#deletemany) #### Options -| Name | Type | Required | Description | -| --------------------- | ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | -| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | -| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| Name | Type | Required | Description | +| ---------------------- | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `where` | `UserWhereUniqueInput` | **Yes** | Wraps all _unique_ fields of a model so that individual records can be selected.

From version 4.5.0, this type wraps all fields of a model. [Learn more](#filter-on-non-unique-fields-with-userwhereuniqueinput) | +| [`select`](#select) | `XOR` | No | [Specifies which properties to include](/orm/prisma-client/queries/select-fields) on the returned object. | +| [`include`](#include) | `XOR` | No | [Specifies which relations should be eagerly loaded](/orm/prisma-client/queries/relation-queries) on the returned object. | +| `relationLoadStrategy` | `'join'` or `'query'` | No | **Default: `join`**. Specifies the [load strategy](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview) for a relation query. Only available in combination with `include` (or `select` on a relation field). In [Preview](/orm/more/releases#preview) since 5.9.0. | #### Return type @@ -1841,6 +1889,57 @@ const usersWithCount = await prisma.user.findMany({ +### relationLoadStrategy (Preview) + +`relationLoadStrategy` specifies how a relation should be loaded from the database. It has two possible values: + +- `join` (default): Uses a database-level `LATERAL JOIN` (PostgreSQL) or correlated subqueries (MySQL) and fetches all data with a single query to the database. +- `query`: Sends multiple queries to the database (one per table) and joins them on the application level. + +> **Note**: Once `relationLoadStrategy` moves from [Preview](/orm/more/releases#preview) into [General Availability](/orm/more/releases/#generally-available-ga), `join` will universally become the default for all relation queries. + +You can learn more about join strategies [here](/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview). + +Because the `relationLoadStrategy` option is currently in Preview, you need to enable it via the `relationJoins` preview feature flag in your Prisma schema file: + +```prisma +generator client { + provider = "prisma-client-js" + previewFeatures = ["relationJoins"] +} +``` + +After adding this flag, you need to run `prisma generate` again to re-generate Prisma Client. This feature is currently available on PostgreSQL, CockroachDB and MySQL. + +#### Remarks + +- In most situations, the default `join` strategy will be more effective. Use `query` if you want to save resources on your database server or if you profiling shows that the application-level join is more performant. +- You can only specify the `relationLoadStrategy` on the top-level in your query. The top-level choice will affect all nested sub-queries. + +#### Examples + +##### Load the `posts` relation via a database-level JOIN when using `include` + +```ts +const users = await prisma.user.findMany({ + relationLoadStrategy: 'join', + include: { + posts: true, + }, +}) +``` + +##### Load the `posts` relation via a database-level JOIN when using `select` + +```ts +const users = await prisma.user.findMany({ + relationLoadStrategy: 'join', + select: { + posts: true, + }, +}) +``` + ### where `where` defines one or more [filters](#filter-conditions-and-operators), and can be used to filter on record properties (like a user's email address) or related record properties (like a user's top 10 most recent post titles). @@ -2676,10 +2775,11 @@ A nested `createMany` query adds a new set of records to a parent record. See: [ #### Remarks - `createMany` is available as a nested query when you `create` (`prisma.user.create(...)`) a new parent record or `update` (`prisma.user.update(...)`) an existing parent record. -- Available in the context of a has-many relation - for example, you can `prisma.user.create(...)` a user and use a nested `createMany` to create multiple posts (posts have one user). -- **Not** available in the context of a many-to-many relation - for example, you **cannot** `prisma.post.create(...)` a post and use a nested `createMany` to create categories (many posts have many categories). -- Does not support nesting additional relations - you cannot nest an additional `create` or `createMany`. -- Allows setting foreign keys directly - for example, setting the `categoryId` on a post. +- Available in the context of a one-to-many relation — for example, you can `prisma.user.create(...)` a user and use a nested `createMany` to create multiple posts (posts have one user). +- **Not** available in the context of a many-to-many relation — for example, you **cannot** `prisma.post.create(...)` a post and use a nested `createMany` to create categories (many posts have many categories). +- Does not support nesting additional relations — you cannot nest an additional `create` or `createMany`. +- Allows setting foreign keys directly — for example, setting the `categoryId` on a post. +- Nested `createMany` is not supported by SQLite. > You can use a nested `create` _or_ a nested `createMany` to create multiple related records - [each technique pros and cons](/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records) . @@ -3091,6 +3191,12 @@ const user = await prisma.user.update({ + + +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. #### Examples @@ -5038,7 +5144,7 @@ In addition, if you are using `$on` or `$use`, you will need to use these client ### $disconnect() -The `$disconnect()` method closes the database connections that were established when `$connect` was called and stops the process that was running Prisma's query engine. See [Connection management](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management) for an overview of `$connect()` and `$disconnect()`. +The `$disconnect()` method closes the database connections that were established when `$connect` was called and stops the process that was running Prisma ORM's query engine. See [Connection management](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management) for an overview of `$connect()` and `$disconnect()`. #### Remarks @@ -5046,7 +5152,7 @@ The `$disconnect()` method closes the database connections that were established ### $connect() -The `$connect()` method establishes a physical connection to the database via Prisma's query engine. See [Connection management](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management) for an overview of `$connect()` and `$disconnect()`. +The `$connect()` method establishes a physical connection to the database via Prisma ORM's query engine. See [Connection management](/orm/prisma-client/setup-and-configuration/databases-connections/connection-management) for an overview of `$connect()` and `$disconnect()`. #### Remarks @@ -5137,12 +5243,12 @@ See: [Transactions](/orm/prisma-client/queries/transactions). ### $metrics -Prisma metrics give you a detailed insight into how Prisma Client interacts with your database. You can use this insight to help diagnose performance issues with your application. Learn more: [Metrics](/orm/prisma-client/observability-and-logging/metrics). +Prisma Client metrics give you a detailed insight into how Prisma Client interacts with your database. You can use this insight to help diagnose performance issues with your application. Learn more: [Metrics](/orm/prisma-client/observability-and-logging/metrics). -Prisma metrics has the following methods: +Prisma Client metrics has the following methods: -- `$metrics.json()`: [Retrieves Prisma metrics in JSON format](/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-json-format). -- `$metrics.prometheus()`: [Retrieves Prisma metrics in Prometheus format](/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-prometheus-format). +- `$metrics.json()`: [Retrieves Prisma Client metrics in JSON format](/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-json-format). +- `$metrics.prometheus()`: [Retrieves Prisma Client metrics in Prometheus format](/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-prometheus-format). ### $extends @@ -5157,7 +5263,7 @@ Learn more: [Prisma Client extensions](/orm/prisma-client/client-extensions). ## Utility types -Utility types are helper functions and types that live on the Prisma namespace. They are useful for keeping your application type safe. +Utility types are helper functions and types that live on the `Prisma` namespace. They are useful for keeping your application type safe. ### Prisma.validator @@ -5236,7 +5342,7 @@ const validateUserAndPostInput = (name, email, postTitle) => { 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 versions 4.3.0 to 4.16.2. +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. 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 239efe1ff7..1fdb4adfee 100644 --- a/content/200-orm/500-reference/100-prisma-schema-reference.mdx +++ b/content/200-orm/500-reference/100-prisma-schema-reference.mdx @@ -15,14 +15,14 @@ Defines a [data source](/orm/prisma-schema/overview/data-sources) in the Prisma A `datasource` block accepts the following fields: -| Name | Required | Type | Description | -| ------------------- | -------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `provider` | **Yes** | String (`postgresql`, `mysql`, `sqlite`, `sqlserver`, `mongodb`, `cockroachdb`) | Describes which data source connectors to use. | -| `url` | **Yes** | String (URL) | Connection URL including authentication info. Most connectors use [the syntax provided by the database](/orm/reference/connection-urls#format). | -| `shadowDatabaseUrl` | No | String (URL) | Connection URL to the shadow database used by Prisma Migrate. Allows you to use a cloud-hosted database as the shadow database. | -| `directUrl` | No | String (URL) | Connection URL for [direct connection to the database](/platform/classic-projects/data-proxy/prisma-cli-with-data-proxy#set-a-direct-database-connection-url-in-your-prisma-schema).

If you use a connection pooler URL in the `url` argument (for example, if you use the Data Proxy or pgBouncer), Prisma CLI commands [that require a direct connection to the database](/platform/classic-projects/data-proxy/prisma-cli-with-data-proxy#prisma-cli-commands-that-require-a-direct-database-connection) use the URL in the `directUrl` argument.

The `directUrl` property is supported by Prisma Studio from version 5.1.0 upwards. | -| `relationMode` | No | String (`foreignKeys`, `prisma`) | Sets whether [referential integrity](/orm/prisma-schema/data-model/relations/relation-mode) is enforced by foreign keys in the database or emulated in the Prisma Client.

In preview in versions 3.1.1 and later. The field is named `relationMode` in versions 4.5.0 and later, and was previously named `referentialIntegrity`. | -| `extensions` | No | List of strings (PostgreSQL extension names) | Allows you to [represent PostgreSQL extensions in your schema](/orm/prisma-schema/postgresql-extensions#how-to-represent-postgresql-extensions-in-your-prisma-schema). Available in preview for PostgreSQL only in Prisma versions 4.5.0 and later. | +| Name | Required | Type | Description | +| ------------------- | -------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `provider` | **Yes** | String (`postgresql`, `mysql`, `sqlite`, `sqlserver`, `mongodb`, `cockroachdb`) | Describes which data source connectors to use. | +| `url` | **Yes** | String (URL) | Connection URL including authentication info. Most connectors use [the syntax provided by the database](/orm/reference/connection-urls#format). | +| `shadowDatabaseUrl` | No | String (URL) | Connection URL to the shadow database used by Prisma Migrate. Allows you to use a cloud-hosted database as the shadow database. | +| `directUrl` | No | String (URL) | Connection URL for direct connection to the database.

If you use a connection pooler URL in the `url` argument (for example, if you use [Prisma Accelerate](/accelerate) or pgBouncer), Prisma CLI commands that require a direct connection to the database use the URL in the `directUrl` argument.

The `directUrl` property is supported by Prisma Studio from version 5.1.0 upwards. | +| `relationMode` | No | String (`foreignKeys`, `prisma`) | Sets whether [referential integrity](/orm/prisma-schema/data-model/relations/relation-mode) is enforced by foreign keys in the database or emulated in the Prisma Client.

In preview in versions 3.1.1 and later. The field is named `relationMode` in versions 4.5.0 and later, and was previously named `referentialIntegrity`. | +| `extensions` | No | List of strings (PostgreSQL extension names) | Allows you to [represent PostgreSQL extensions in your schema](/orm/prisma-schema/postgresql-extensions#how-to-represent-postgresql-extensions-in-your-prisma-schema). Available in preview for PostgreSQL only in Prisma ORM versions 4.5.0 and later. | The following providers are available: @@ -199,7 +199,7 @@ Unless specified otherwise, the default supported CPU architecture is x86_64. | Alpine (3.17 and newer) | `linux-musl-openssl-3.0.x`\* | 3.0.x | | Alpine (3.16 and older) | `linux-musl` | 1.1.x | -\* Available in Prisma versions 4.8.0 and later. +\* Available in Prisma ORM versions 4.8.0 and later. ##### Linux (Alpine on ARM64 architectures) @@ -208,7 +208,7 @@ Unless specified otherwise, the default supported CPU architecture is x86_64. | Alpine (3.17 and newer) | `linux-musl-arm64-openssl-3.0.x`\* | 3.0.x | | Alpine (3.16 and older) | `linux-musl-arm64-openssl-1.1.x`\* | 1.1.x | -\* Available in Prisma versions 4.10.0 and later. +\* Available in Prisma ORM versions 4.10.0 and later. ##### Linux (Debian), x86_64 @@ -345,7 +345,7 @@ Defines a Prisma [model](/orm/prisma-schema/data-model/models#defining-models) . - Model names must adhere to the following regular expression: `[A-Za-z][A-Za-z0-9_]*` - Model names must start with a letter and are typically spelled in [PascalCase](https://wiki.c2.com/?PascalCase) - Model names should use the singular form (for example, `User` instead of `user`, `users` or `Users`) -- Prisma has a number of **reserved words** that are being used by Prisma internally and therefore cannot be used as a model name. You can find the reserved words [here](https://github.com/prisma/prisma/blob/main/packages/client/src/generation/generateClient.ts#L376) and [here](https://github.com/prisma/prisma-engines/blob/main/psl/parser-database/src/names/reserved_model_names.rs#L44). +- Prisma ORM has a number of **reserved words** that are being used by Prisma ORM internally and therefore cannot be used as a model name. You can find the reserved words [here](https://github.com/prisma/prisma/blob/main/packages/client/src/generation/generateClient.ts#L376) and [here](https://github.com/prisma/prisma-engines/blob/main/psl/parser-database/src/names/reserved_model_names.rs#L44). > **Note**: You can use the [`@@map` attribute](#map-1) to map a model (for example, `User`) to a table with a different name that does not match model naming conventions (for example, `users`). @@ -397,7 +397,7 @@ model User { ## model field scalar types -The _data source connector_ determines what _native database type_ each of Prisma scalar type maps to. Similarly, the _generator_ determines what _type in the target programming language_ each of these types map to. +The _data source connector_ determines what _native database type_ each of Prisma ORM scalar type maps to. Similarly, the _generator_ determines what _type in the target programming language_ each of these types map to. Prisma models also have [model field types](/orm/prisma-schema/data-model/relations) that define relations between models. @@ -686,7 +686,7 @@ True or false value. Floating point number. -> `Float` maps to `Double` in [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later - see [release notes](https://github.com/prisma/prisma/releases/tag/2.17.0) and [Video: Changes to the default mapping of Float in Prisma 2.17.0](https://www.youtube.com/watch?v=OsuGP_xNHco&%3Bab_channel=Prisma) for more information about this change. +> `Float` maps to `Double` in [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later - see [release notes](https://github.com/prisma/prisma/releases/tag/2.17.0) and [Video: Changes to the default mapping of Float in Prisma ORM 2.17.0](https://www.youtube.com/watch?v=OsuGP_xNHco&%3Bab_channel=Prisma) for more information about this change. #### Default type mappings @@ -1021,7 +1021,7 @@ The `Unsupported` type was introduced in [2.17.0](https://github.com/prisma/pris - Fields with `Unsupported` types are not available in the generated client. - If a model contains a **required** `Unsupported` type, `prisma.model.create(..)`, `prisma.model.update(...)` and `prisma.model.upsert(...)` are not available in Prisma Client. -- When you introspect a database that contains unsupported types, Prisma will provide the following warning: +- When you introspect a database that contains unsupported types, Prisma ORM will provide the following warning: ``` *** WARNING *** @@ -2840,7 +2840,7 @@ Automatically stores the time when a record was last updated. If you do not supp #### Remarks - Compatible with [`DateTime`](#datetime) fields -- Implemented at Prisma level +- Implemented at Prisma ORM level #### Arguments @@ -2881,11 +2881,11 @@ model Post { -Add `@ignore` to a field that you want to exclude from Prisma Client (for example, a field that you do not want Prisma users to update). Ignored fields are excluded from the generated Prisma Client. The model's `create` method is disabled when doing this for _required_ fields with no `@default` (because the database cannot create an entry without that data). +Add `@ignore` to a field that you want to exclude from Prisma Client (for example, a field that you do not want Prisma Client users to update). Ignored fields are excluded from the generated Prisma Client. The model's `create` method is disabled when doing this for _required_ fields with no `@default` (because the database cannot create an entry without that data). #### Remarks -- In [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later, Prisma automatically adds `@ignore` to fields that _refer to_ invalid models when you introspect. +- In [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later, Prisma ORM automatically adds `@ignore` to fields that _refer to_ invalid models when you introspect. #### Examples @@ -2907,7 +2907,7 @@ Add `@@ignore` to a model that you want to exclude from Prisma Client (for examp #### Remarks -- In [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later, Prisma adds `@@ignore` to an invalid model. (It also adds [`@ignore`](#ignore) to relations pointing to such a model) +- In [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later, Prisma ORM adds `@@ignore` to an invalid model. (It also adds [`@ignore`](#ignore) to relations pointing to such a model) #### Examples @@ -3137,8 +3137,8 @@ Generate a globally unique identifier based on the [`cuid`](https://github.com/e #### Remarks - Compatible with `String` -- Implemented by Prisma and therefore not "visible" in the underlying database schema. You can still use `cuid()` when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma's [query engine](/orm/more/under-the-hood/engines). -- Since the length of `cuid()` output is undefined per the cuid creator, a safe field size is 30 characters, in order to allow for enough characters for very large values. If you set the field size as less than 30, and then a larger value is generated by `cuid()`, you might see Prisma errors such as `Error: The provided value for the column is too long for the column's type.` +- Implemented by Prisma ORM and therefore not "visible" in the underlying database schema. You can still use `cuid()` when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma's [query engine](/orm/more/under-the-hood/engines). +- Since the length of `cuid()` output is undefined per the cuid creator, a safe field size is 30 characters, in order to allow for enough characters for very large values. If you set the field size as less than 30, and then a larger value is generated by `cuid()`, you might see Prisma Client errors such as `Error: The provided value for the column is too long for the column's type.` ##### MongoDB @@ -3178,11 +3178,11 @@ Generate a globally unique identifier based on the [UUID](https://en.wikipedia.o #### Remarks - Compatible with `String` -- Implemented by Prisma and therefore not "visible" in the underlying database schema. You can still use `uuid()` when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma's [query engine](/orm/more/under-the-hood/engines). +- Implemented by Prisma ORM and therefore not "visible" in the underlying database schema. You can still use `uuid()` when using [introspection](/orm/prisma-schema/introspection) by [manually changing your Prisma schema](/orm/prisma-client/setup-and-configuration/custom-model-and-field-names) and [generating Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client), in that case the values will be generated by Prisma ORM's [query engine](/orm/more/under-the-hood/engines). -**Note (Relational databases)**: If you do not want to use Prisma's `uuid()` function, you can use [the native database function with `dbgenerated`](#override-default-value-behavior-for-supported-types). +**Note (Relational databases)**: If you do not want to use Prisma ORM's `uuid()` function, you can use [the native database function with `dbgenerated`](#override-default-value-behavior-for-supported-types). @@ -3240,7 +3240,7 @@ Set a timestamp of the time when a record is created. ##### MongoDB -- Implemented at Prisma level +- Implemented at Prisma ORM level #### Examples @@ -3307,7 +3307,7 @@ circle Unsupported("circle")? @default(dbgenerated("'<(10,4),11>'::circle" ]}> -You can also use `dbgenerated()` to set the default value for supported types. For example, in PostgreSQL you can generate UUIDs at the database level rather than rely on Prisma's `uuid()`: +You can also use `dbgenerated()` to set the default value for supported types. For example, in PostgreSQL you can generate UUIDs at the database level rather than rely on Prisma ORM's `uuid()`: ```prisma highlight=2;add|3;delete model User { @@ -3324,7 +3324,7 @@ model User { -**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 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). +**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).
@@ -3340,7 +3340,7 @@ A variable length text in double quotes: `""`, `"Hello World"`, `"Alice"` ### Expression -An expression that can be evaluated by Prisma: `42.0`, `""`, `Bob`, `now()`, `cuid()` +An expression that can be evaluated by Prisma ORM: `42.0`, `""`, `Bob`, `now()`, `cuid()` ## enum @@ -3356,7 +3356,7 @@ Defines an [enum](/orm/prisma-schema/data-model/models#defining-enums) . ### Remarks - Enums are natively supported by [PostgreSQL](https://www.postgresql.org/docs/current/datatype-enum.html) and [MySQL](https://dev.mysql.com/doc/refman/8.0/en/enum.html) -- Enums are implemented and enforced at Prisma level in MongoDB +- Enums are implemented and enforced at Prisma ORM level in MongoDB ### Naming conventions 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 e7b884ef2c..dc12677c7d 100644 --- a/content/200-orm/500-reference/200-prisma-cli-reference.mdx +++ b/content/200-orm/500-reference/200-prisma-cli-reference.mdx @@ -122,7 +122,7 @@ Environment variables loaded from .env ### init -Bootstraps a fresh Prisma project within the current directory. +Bootstraps a fresh Prisma ORM project within the current directory. The `init` command does not interpret any existing files. Instead, it creates a `prisma` directory containing a bare-bones `schema.prisma` file within your current directory. @@ -176,7 +176,7 @@ https://pris.ly/d/getting-started prisma init --datasource-provider sqlite ``` -The command output contains helpful information on how to use the generated files and begin using Prisma with your project. +The command output contains helpful information on how to use the generated files and begin using Prisma ORM with your project. #### Run `prisma init --preview-feature` @@ -334,18 +334,18 @@ generator client { #### Options -| Option | Required | Description | Default | -| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `--data-proxy` | No | The `generate` command will generate Prisma Client for use with the [Data Proxy](/platform/classic-projects/data-proxy). Mutually exclusive with `--accelerate` and `--no-engine`. | -| `--accelerate` | No | The `generate` command will generate Prisma Client for use with [Accelerate](/accelerate). Mutually exclusive with `--data-proxy` and `--no-engine`. Available in Prisma 5.1.0 and later. | -| `--no-engine` | No | The `generate` command will generate Prisma Client without an accompanied engine for use with [Data Proxy](/platform/classic-projects/data-proxy) or [Accelerate](/accelerate). Mutually exclusive with `--data-proxy` and `--accelerate`. Available in Prisma 5.2.0 and later. | -| `--watch` | No | The `generate` command will continue to watch the `schema.prisma` file and re-generate Prisma Client on file changes. | +| Option | Required | Description | Default | +| -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `--data-proxy` | No | The `generate` command will generate Prisma Client for use with [Prisma Accelerate](/accelerate) prior to Prisma 5.0.0. Mutually exclusive with `--accelerate` and `--no-engine`. | +| `--accelerate` | No | The `generate` command will generate Prisma Client for use with [Prisma Accelerate](/accelerate). Mutually exclusive with `--data-proxy` and `--no-engine`. Available in Prisma 5.1.0 and later. | +| `--no-engine` | No | The `generate` command will generate Prisma Client without an accompanied engine for use with [Prisma Accelerate](/accelerate). Mutually exclusive with `--data-proxy` and `--accelerate`. Available in Prisma ORM 5.2.0 and later. | +| `--watch` | No | The `generate` command will continue to watch the `schema.prisma` file and re-generate Prisma Client on file changes. | **Deprecation Warning** -As of Prisma 5.2.0, `--data-proxy` and `--accelerate` are deprecated in favor of `--no-engine` as Prisma Client no longer requires an option to work with Accelerate or Data Proxy. All options are available and work similarly, but we recommend `--no-engine` as it prevents an engine from being downloaded which will greatly impact the size of apps deployed to serverless and edge functions. +As of Prisma 5.2.0, `--data-proxy` and `--accelerate` are deprecated in favor of `--no-engine` as Prisma Client no longer requires an option to work with Prisma Accelerate. All options are available and work similarly, but we recommend `--no-engine` as it prevents an engine from being downloaded which will greatly impact the size of apps deployed to serverless and edge functions. @@ -440,7 +440,7 @@ The `prisma-client-js` generator creates a customized client for working with yo **Deprecation warning**
-From Prisma 3.0.0 onwards, the `prisma introspect` command is deprecated and replaced with the [`prisma db pull`](#db-pull) command. +From Prisma ORM 3.0.0 onwards, the `prisma introspect` command is deprecated and replaced with the [`prisma db pull`](#db-pull) command.
@@ -762,7 +762,7 @@ prisma db pull ```code no-copy Introspecting based on datasource defined in schema.prisma … -✔ Wrote Prisma data model into schema.prisma in 38ms +✔ Introspected 2 models and wrote them into schema.prisma in 38ms Run prisma generate to generate Prisma Client. ``` @@ -788,7 +788,7 @@ prisma db pull --schema=./alternative/schema.prisma ```code no-copy Introspecting based on datasource defined in alternative/schema.prisma … -✔ Wrote Prisma data model into alternative/schema.prisma in 60ms +✔ Introspected 2 models and wrote them into alternative/schema.prisma in 60ms Run prisma generate to generate Prisma Client. ``` @@ -1269,7 +1269,7 @@ where the `--from-...` and `--to-...` options are selected based on the type of - live databases - migration histories -- Prisma data models +- Prisma schema data models - an empty schema Both schema sources must use the same database provider. For example, a diff comparing a PostgreSQL data source with a SQLite data source is not supported. @@ -1342,6 +1342,52 @@ Other options: --script > script.sql ``` +## Prisma Data Platform + +### platform ([Early Access](/platform/maturity-levels#early-access)) + +The `platform` command provides access to the Prisma Data Platform through the Prisma CLI starting in version `5.10.0` or later. + +- **Authentication**: + + - `platform auth login`: Opens a browser window for login or account creation. + - `platform auth logout`: Logs out of the platform. + - `platform auth show`: Displays information about the currently authenticated user. + +- **Workspace Management**: + + - `platform workspace show`: Lists all workspaces available to your account. + +- **Project Management**: + + - `platform project show`: Lists all projects within the specified workspace. + - `platform project create`: Creates a new project within the specified workspace. + - `platform project delete`: Deletes the specified project. + +- **Environment Management**: + + - `platform environment show`: Lists all environments for the specified project. + - `platform environment create`: Creates a new environment within the specified project. + - `platform environment delete`: Deletes the specified environment. + +- **API Key Management**: + + - `platform apikey show`: Lists all API keys for the specified environment. + - `platform apikey create`: Creates a new API key for the specified environment. + - `platform apikey delete`: Deletes the specified API key. + +- **Prisma Accelerate**: + + - `platform accelerate enable`: Enables Prisma Accelerate for the specified environment. + - `platform accelerate disable`: Disables Prisma Accelerate for the specified environment. + +- **Prisma Pulse**: + + - `platform pulse enable`: Enables Prisma Pulse for the specified environment. + - `platform pulse disable`: Disables Prisma Pulse for the specified environment. + +You can find the complete list of available commands with the arguments [here](/platform/platform-cli/commands). + ## Studio ### studio diff --git a/content/200-orm/500-reference/250-error-reference.mdx b/content/200-orm/500-reference/250-error-reference.mdx index f1cb20b2cf..ff968a5a33 100644 --- a/content/200-orm/500-reference/250-error-reference.mdx +++ b/content/200-orm/500-reference/250-error-reference.mdx @@ -120,7 +120,7 @@ Prisma Client throws a `PrismaClientValidationError` exception if validation fai #### P1012 -**Note:** If you get error code P1012 after you upgrade Prisma to version 4.0.0 or later, see the [version 4.0.0 upgrade guide](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-4#upgrade-your-prisma-schema). A schema that was valid before version 4.0.0 might be invalid in version 4.0.0 and later. The upgrade guide explains how to update your schema to make it valid. +**Note:** If you get error code P1012 after you upgrade Prisma ORM to version 4.0.0 or later, see the [version 4.0.0 upgrade guide](/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-4#upgrade-your-prisma-schema). A schema that was valid before version 4.0.0 might be invalid in version 4.0.0 and later. The upgrade guide explains how to update your schema to make it valid. "{full_error}" @@ -300,6 +300,10 @@ Possible P1012 error messages: "Transaction API error: {error}" +#### P2029 + +"Query parameter limit exceeded error: {message}" + #### P2030 "Cannot find a fulltext index to use for the search, try adding a @@fulltext([Fields...]) to your schema" @@ -316,6 +320,18 @@ Possible P1012 error messages: "Transaction failed due to a write conflict or a deadlock. Please retry your transaction" +#### P2035 + +"Assertion violation on the database: {database_error}" + +#### P2036 + +"Error in external connector (id {id})" + +#### P2037 + +"Too many database connections opened: {message}" + ### Prisma Migrate (Schema Engine) @@ -434,94 +450,6 @@ Original error: {error_code}
{inner_error}" -### Data Proxy - -Because Data Proxy connections operate differently from local database connections, error codes are different from regular ones. In general, all Data Proxy-related errors start with `P5xxx`. - -#### P5000 - -This request could not be understood by the server - -#### P5001 - -This request must be retried - -#### P5002 - -The datasource provided is invalid: - -- Could not parse the URL of the datasource -- Datasource URL must use `prisma://` protocol when `--data-proxy`, `--accelerate`, or `--no-engine` is used -- No valid API key found - -#### P5003 - -Requested resource does not exist - -#### P5004 - -The feature is not yet implemented: - -- `beforeExit` event is not yet supported - -#### P5005 - -Schema needs to be uploaded - -#### P5006 - -Unknown server error - -#### P5007 - -Unauthorized, check your connection string - -#### P5008 - -Usage exceeded, retry again later - -#### P5009 - -Request timed out - -#### P5010 - -Cannot fetch data from service - -#### P5011 - -Request parameters are invalid. - - - -**Note**

- -You see error P5000 when the server cannot understand the request.

- -In comparison, P5011 indicates that the server understands the request but rejects it due to failed validation checks, such as parameters being out of range. - -
- -#### P5012 - -Engine version is not supported - -#### P5013 - -Engine not started: healthcheck timeout - -#### P5014 - -Unknown engine startup error (contains message and logs) - -#### P5015 - -Interactive transaction error: - -- Could not parse interactive transaction ID -- Could not find Query Engine for the specified host and transaction ID -- Could not start interactive transaction - ### Prisma Accelerate Prisma Accelerate-related errors start with `P6xxx`. @@ -546,6 +474,8 @@ The included usage of the current plan has been exceeded. This can only occur on The global timeout of Accelerate has been exceeded. You can find the limit [here](/accelerate/limitations#query-timeout-limit). +> Also see the [troubleshooting guide](/accelerate/troubleshoot#p6004-querytimeout) for more information. + #### P6005 (InvalidParameters) The user supplied invalid parameters. Currently only relevant for transaction methods. For example, setting a timeout that is too high. You can find the limit [here](/accelerate/limitations#interactive-transactions-query-timeout-limit). @@ -558,6 +488,45 @@ The chosen Prisma version is not compatible with Accelerate. This may occur when The engine failed to start. For example, it couldn't establish a connection to the database. +> Also see the [troubleshooting guide](/accelerate/troubleshoot#p6008-connectionerrorenginestarterror) for more information. + #### P6009 (ResponseSizeLimitExceeded) The global response size limit of Accelerate has been exceeded. You can find the limit [here](/accelerate/limitations#response-size-limit). + +> Also see the [troubleshooting guide](/accelerate/troubleshoot#p6009-responsesizelimitexceeded) for more information. + +### Prisma Pulse + +Prisma Pulse-related errors start with P61xx. + +#### P6100 (ServerError) – HTTP Status 500 + +An unexpected server error occurred. +This can happen due to a technical issue within the Prisma Pulse or its infrastructure. +For any incidents related to Prisma Pulse, you can refer to our status page [here](https://www.prisma-status.com/) and reach out to our support team through one of our available [channels](/platform/support) to report your issue. + +#### P6101 (DatasourceError) – HTTP Status 400 + +Reasons: + +1. The datasource is not reachable by Prisma Pulse. The Console will validate the connection when enabling Pulse to reduce the likelihood of this error. However, the datasource may become unavailable after the configuration step, resulting in this error. +2. The datasource is reachable, but did not meet the requirements for Prisma Pulse. The Console will validate the configuration when enabling Pulse to reduce the likelihood of this error. However, the datasource may change after the configuration step, resulting in this error. + +#### P6102 (Unauthorized) – HTTP Status 400 + +The API key is invalid. + +#### P6103 (ProjectDisabledError) – HTTP Status 400 + +Prisma Pulse is not enabled for the configured API key. + +#### P6104 (AccountHoldError) – HTTP Status 400 + +Your Prisma Data Platform account has been blocked, potentially due to exceeding the usage limit included in your current plan. Please review the error message for further information. + +If you require further assistance, please get in touch with us via one of our support [channels](/platform/support). + +#### P6105 (VersionNotSupported) – HTTP Status 400 + +The Prisma version of the project is not compatible with Prisma Pulse. 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 0051b9a62e..5d674bfa0c 100644 --- a/content/200-orm/500-reference/300-environment-variables-reference.mdx +++ b/content/200-orm/500-reference/300-environment-variables-reference.mdx @@ -73,16 +73,6 @@ See [Studio](/orm/reference/prisma-cli-reference#studio) documentation for more Disables all CLI warnings generated by `logger.warn`. -### PRISMA_GENERATE_DATAPROXY - - - -**Deprecated**: `PRISMA_GENERATE_DATAPROXY` is deprecated in [5.2.0](https://github.com/prisma/prisma/releases/tag/5.2.0) as `--accelerate` and `--data-proxy` are no longer required to use Accelerate or Data Proxy. To get the same behavior as before, you can use the [`PRISMA_GENERATE_NO_ENGINE`](#prisma_generate_no_engine) environment variable. - - - -To configure `prisma generate` to [generate a Prisma Client for Data Proxy](/platform/classic-projects/data-proxy) on any execution, even when `--data-proxy` is not explicitly set for the CLI command, set the value of this environment value to a truthy value (e.g. `PRISMA_GENERATE_DATAPROXY=true`). - ### PRISMA_GENERATE_NO_ENGINE @@ -91,7 +81,7 @@ This environment variable is available since version `5.2.0` -`PRISMA_GENERATE_NO_ENGINE` can be set to a truthy value to generate a Prisma Client without an included [query engine](/orm/more/under-the-hood/engines) in order to reduce deployed application size when paired with [Prisma Data Proxy](/platform/classic-projects/data-proxy) or [Prisma Accelerate](/accelerate). +`PRISMA_GENERATE_NO_ENGINE` can be set to a truthy value to generate a Prisma Client without an included [query engine](/orm/more/under-the-hood/engines) in order to reduce deployed application size when paired with [Prisma Accelerate](/accelerate). ### PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK @@ -167,7 +157,7 @@ PRISMA_ENGINES_MIRROR=https://example.org/custom-engines/ See [Prisma engines](/orm/more/under-the-hood/engines#hosting-engines) for a conceptual overview of how to use this environment variable. -Note: This environment variable used to be available as `PRISMA_BINARIES_MIRROR`, which was deprecated in Prisma 3.0.1. It is discouraged to use anymore and will be removed in the future. +Note: This environment variable used to be available as `PRISMA_BINARIES_MIRROR`, which was deprecated in Prisma ORM 3.0.1. It is discouraged to use anymore and will be removed in the future. #### PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING @@ -177,7 +167,7 @@ This environment variable is available since version `4.16.0`
-`PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING` can be can be set to a truthy value to ignore problems around downloading & verifying the integrity (via a checksum file) of the Prisma engines. +`PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING` can be can be set to a truthy value to ignore problems around downloading & verifying the integrity (via a checksum file) of the Prisma ORM engines. This is particularly useful when deploying to an offline system environment where the checksum file cannot be downloaded. ```env @@ -280,10 +270,12 @@ The `PRISMA_FMT_BINARY` variable is used in versions [4.2.0](https://github.com/ `PRISMA_CLI_BINARY_TARGETS` can be used to specify one or more binary targets that Prisma CLI will download during installation (so it must be provided during `npm install` of Prisma CLI and does not affect runtime of Prisma CLI or Prisma Client). -Use `PRISMA_CLI_BINARY_TARGETS` if you 1) deploy to a specific platform via an upload of a local project that includes dependencies, and 2) your local environment is different from the target (e.g. AWS Lambda is `rhel-openssl-1.0.x`, and your local environment might be macOS arm64 `darwin-arm64`). Using the `PRISMA_CLI_BINARY_TARGETS` environment variable ensures that the target engine files are also downloaded. +Use `PRISMA_CLI_BINARY_TARGETS` if you 1) deploy to a specific platform via an upload of a local project that includes dependencies, and 2) your local environment is different from the target (e.g. AWS Lambda with Node.js 20+ is `rhel-openssl-3.0.x`, and your local environment might be macOS arm64 `darwin-arm64`). Using the `PRISMA_CLI_BINARY_TARGETS` environment variable ensures that the target engine files are also downloaded. ```terminal -PRISMA_CLI_BINARY_TARGETS=darwin-arm64,rhel-openssl-1.0.x npm install +PRISMA_CLI_BINARY_TARGETS=darwin-arm64,rhel-openssl-3.0.x npm install ``` This is the Prisma CLI equivalent for the [`binaryTargets` property of the `generator` block](/orm/prisma-schema/overview/generators#binary-targets), which enables you to define the same setting for Prisma Client. + +> **Note**: For Node.js versions earlier than 20, the openssl version was 1.0.x instead of 3.0.x. This is most obvious in AWS Lambda deployments, where the binary target would be `rhel-openssl-1.0.x` instead of `rhel-openssl-3.0.x`. diff --git a/content/200-orm/500-reference/350-database-features.mdx b/content/200-orm/500-reference/350-database-features.mdx index 11a545a45c..1b2b3a4d58 100644 --- a/content/200-orm/500-reference/350-database-features.mdx +++ b/content/200-orm/500-reference/350-database-features.mdx @@ -1,22 +1,22 @@ --- title: 'Database features matrix' metaTitle: 'Database features matrix' -metaDescription: 'Learn which database features are supported in Prisma and how they map to the different Prisma tools.' +metaDescription: 'Learn which database features are supported in Prisma ORM and how they map to the different Prisma ORM tools.' wide: true tocDepth: 3 --- -This page gives an overview of the features which are provided by the databases that Prisma supports. Additionally, it explains how each of these features can be used in Prisma with pointers to further documentation. +This page gives an overview of the features which are provided by the databases that Prisma ORM supports. Additionally, it explains how each of these features can be used in Prisma ORM with pointers to further documentation. -> **Note**: If a feature is not supported natively by the database, it's also not available in Prisma. +> **Note**: If a feature is not supported natively by the database, it's also not available in Prisma ORM. ## Relational database features -This section describes which database features exist on the relational databases that are currently supported by Prisma. The **Prisma schema** column indicates how a certain feature can be represented in the [Prisma schema](/orm/prisma-schema) and links to its documentation. Note that database features can be used in **Prisma Client** even though they might not yet be representable in the Prisma schema. +This section describes which database features exist on the relational databases that are currently supported by Prisma ORM. The **Prisma schema** column indicates how a certain feature can be represented in the [Prisma schema](/orm/prisma-schema) and links to its documentation. Note that database features can be used in **Prisma Client** even though they might not yet be representable in the Prisma schema. ### Constraints @@ -68,7 +68,7 @@ Algorithm specified via `USING`: | SP-GiST | ✔️ | ✔️ | No | No | ✔️ | ✔️† | ✔️\* | Not yet | - \* Only available if natively supported by database. -- † Available with the PostgreSQL connector only in Prisma versions `4.0.0` and later. +- † Available with the PostgreSQL connector only in Prisma ORM versions `4.0.0` and later. -You must wrap your filter criteria inside a `before` or `after` object depending on the type of event your subscription is listening for: +You may have to wrap your filter criteria inside a `after` object depending on the type of event your subscription is listening for: + +- `after`: `update` events -- `before`: `delete` events -- `after`: `create` and `update` events +This makes it explicit that the specified filter criteria apply to the `after` state of the change event. -This makes it explicit that the specified filter criteria apply to the `before` or `after` state of the change event. + + +All [`create`](#create) event results implicitly represent the `after` state of the change event. And all [`delete`](#delete) event results implicitly represent the `before` state of the change event. + + @@ -178,38 +210,6 @@ Using a filter inside of `after` will return changed records that match your fil ##### Examples -Get `create` events where the value of name is equal to `'Jim'` after the event has occurred: - - - - -```ts -const subscription = await prisma.user.subscribe({ - create: { - after: { - name: 'Jim', - }, - }, -}) -``` - - - - -```ts no-copy -{ - action: 'create', - after: { - id: 6, - email: 'test@test.com', - name: 'Jim' - } -} -``` - - - - Get `update` events where the value of name is equal to `Jim` after the event has occurred: @@ -241,47 +241,3 @@ const subscription = await prisma.user.subscribe({ - -#### Usage in the before state filter - -Using a filter inside of `before` will return changed records that match your filter criteria as applied to the state of the record before the change event. - -##### Example - -Get delete events where the value of name was equal to Marc. - - - - -```ts -const subscription = await prisma.user.subscribe({ - delete: { - before: { - name: 'Jim', - }, - }, -}) -``` - - - - -```ts no-copy -{ - action: 'update', - after: { - id: 6, - email: 'updated@test.com', - name: 'Jim', - } -} -``` - - - - - - -Specifying a filter condition for delete events only works if you’ve set the table’s `REPLICA IDENTITY` to `FULL`. See [this section](/pulse/api-reference#delete) for more details. - - diff --git a/content/400-pulse/500-current-limitations.mdx b/content/400-pulse/500-current-limitations.mdx deleted file mode 100644 index d3c6637d3b..0000000000 --- a/content/400-pulse/500-current-limitations.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: 'Current limitations' -metaTitle: 'Pulse: Current limitations' -metaDescription: 'Learn about current limitations of Pulse.' -tocDepth: 3 -toc: true ---- - - - -Below are descriptions of known limitations when using Pulse. If you are aware of any limitations that are missing, please let us know on the [#pulse-feedback](https://prisma.slack.com/archives/C058GKE3C1E) channel in our community Slack. - - - -## Superuser account required - -You must connect to your database instance from Pulse using a superuser account. In the future, we will enable non-superuser accounts with limited access privileges to be used with Pulse. - -## Limited throughput of change events - -While in Early Access, there may be limits to the throughput of change events that can be captured and delivered. We plan to provide transparent scale-up capabilities in the future. - -## Limited to 10 active subscriptions per table - -Initially you will be limited to 10 active subscriptions per table. This limitation will be lifted in the future. - -## Change events are not persisted - -Pulse does not persist change events and does not provide delivery guarantees with regards to ordering or exact-once/at-least-once delivery. - -An application must maintain an active connection to Pulse using the `subscribe()` method to capture change events; change events that occur while a Prisma Client is not subscribed will not be delivered. - -## Front-end use is not possible - -Pulse cannot be used in the front-end portion of an application. - - - -If you would find this capability valuable, please share your thoughts on the[#pulse-feedback](https://prisma.slack.com/archives/C058GKE3C1E) channel on our community Slack. - - - -## Limited to Postgres versions 12 or higher - -Pulse is currently supported with Postgres versions 12 or higher. It should work with most Postgres providers that expose Postgres’ native logical replication feature. We plan on adding support for MySQL in our GA release. - - - -If you have questions about whether your database is supported, please reach out to us on the [#pulse-feedback](https://prisma.slack.com/archives/C058GKE3C1E) channel on our community Slack. - - - -## Pulse will not attempt a reconnect or give an indication of the network is disconnected - -Currently, if there is some type of network disconnect while Prisma Client is subscribed to Pulse, there will be no attempts to reconnect or indicate the connection has dropped. - -For example, if you are evaluating Pulse from an application running on your laptop and it goes to sleep resulting in a network disruption, it can appear as though the Prisma Client instance is still subscribed to Pulse when it is not. - -We will soon add heart-beating capability that throws an error to the Prisma Client when the connection is no longer active so the application can reconnect. diff --git a/content/400-pulse/500-known-limitations.mdx b/content/400-pulse/500-known-limitations.mdx new file mode 100644 index 0000000000..d892ef8f42 --- /dev/null +++ b/content/400-pulse/500-known-limitations.mdx @@ -0,0 +1,62 @@ +--- +title: 'Known limitations' +metaTitle: 'Pulse: Known limitations' +metaDescription: 'Learn about known limitations of Pulse.' +tocDepth: 3 +toc: true +--- + + + +Below are descriptions of known limitations when using Prisma Pulse. If you are aware of any limitations that are missing, please let us know on the `#help-and-questions` channel in our community [Discord](https://pris.ly/discord). + + + +## Superuser role required for starter plan + +Our [Starter plan](https://www.prisma.io/pricing) requires a database role with superuser access. + +## Database events are not persisted + +Prisma Pulse does not persist database events and does not provide delivery guarantees regarding ordering or exact-once/at-least-once delivery. + +To capture database events, an application must maintain an active connection to Pulse using the  [`subscribe()`](/pulse/api-reference#subscribe) method. + +It's important to note scenarios where database events may not be delivered: + +1. **Inactive subscriptions**: If no active subscriptions match the filters of the database event. +2. **Exceeding database event size limits**: Database events surpassing predefined size limits. + +## Prisma Pulse is server-side + +Prisma Pulse subscriptions cannot be initiated directly within client-side code. + +## Limited to Postgres versions 12 or higher + +Prisma Pulse is currently supported with Postgres versions 12 or higher. It should work with most Postgres providers that expose Postgres’ native logical replication feature. + +## Subscription type limitation with custom publication slots + +Our advanced onboarding flow enables you to provide a [custom publication slot](/pulse/database-setup/general-database-instructions#manage-your-own-publication-slot). Should that custom publication slot only contains a subset of your database tables, the Prisma Client generated with the Pulse Client Extension will continue to permit subscriptions to all models based on the entirety of your Prisma Schema definitions. + +For example, if you have two models in your schema, the `User` and `Post` model. And you opt to create a publication to monitor changes in the `User` model exclusively: + +```sql +CREATE PUBLICATION user_publication FOR TABLE users; +``` + +> To learn more about creating custom publication slots, see [managing your publication slot](https://www.prisma.io/docs/pulse/database-setup/general-database-instructions#manage-your-own-publication-slot). + +Your resulting subscription code would be: + +```ts +const userSubscription = prisma.user.subscribe() +``` + +However, despite the absence of publication coverage, the generated Prisma client permits subscriptions for all models, such as the `Post` model: + +```ts +const postSubscription = prisma.post.subscribe() +``` + +> We are actively working on enhancing type generation for custom publications as part of our ongoing efforts to further refine Prisma Pulse. diff --git a/content/400-pulse/600-faq.mdx b/content/400-pulse/600-faq.mdx index 33efe0bb29..b824b28054 100644 --- a/content/400-pulse/600-faq.mdx +++ b/content/400-pulse/600-faq.mdx @@ -1,39 +1,58 @@ --- title: 'FAQ' -metaTitle: 'Pulse: FAQ' -metaDescription: 'Frequently asked questions about Pulse.' +metaTitle: 'Prisma Pulse: FAQ' +metaDescription: 'Frequently asked questions about Prisma Pulse.' tocDepth: 3 toc: true --- -Below are frequently asked questions about Pulse. + -## Does Pulse work in a serverless environment? +Below are frequently asked questions about Prisma Pulse. -Pulse will natively support serverless environments soon after it launches to [General Availability](/platform/platform-console/maturity-levels#general-availability). + -While in [Early Access](/platform/platform-console/maturity-levels#early-access), Pulse works best when it is able to maintain a long-running active connection with your application. However, many serverless runtime providers limit the duration of serverless functions. We’re actively working on improving the experience in serverless applications. +## What databases are supported with Prisma Pulse? + +Currently, Pulse supports PostgreSQL. We plan to broaden support to include more databases soon. -Please reach out to us on the [#pulse-feedback](https://prisma.slack.com/archives/C058GKE3C1E) channel on our community Slack if having a more native serverless approach to getting data change events is important to you. +Note: Pulse compatibility with Postgres-like databases depends on their logical replication capabilities. -## How does Pulse handle schema changes in the database? + -Pulse is designed to work seamlessly with schema changes in your database by utilizing [Change data capture (CDC)](https://en.wikipedia.org/wiki/Change_data_capture) techniques, leveraging technologies like [Debezium](https://debezium.io/), and combining that with the power of schema-driven data access using [Prisma Client](/orm/prisma-client). When your Prisma schema is updated, Pulse automatically adapts to the changes, ensuring that your real-time data synchronization remains consistent and reliable. +Prisma Pulse’s database compatibility list will be different from Prisma Client's database compatibility list. If you want to use Prisma Pulse with an existing application using Prisma ORM, please verify the database and hosting provider are supported. -Pulse leverages the type information generated by Prisma to create type-safe database subscriptions, allowing you to catch potential issues at compile time and maintain the integrity of your data throughout the development process. This approach allows Pulse to efficiently capture and propagate data changes while maintaining compatibility with evolving database structures. + -## What databases are supported with Pulse? +### What database providers are supported with Prisma Pulse? -The Pulse Early Access release supports PostgreSQL with plans to extend support to MySQL in the near future. +| Provider | Starter | Pro | Business | Enterprise | +| -------- | ------- | --- | -------- | ---------- | +| Railway | ✅ | ✅ | ✅ | ✅ | +| Supabase | ✅ | ✅ | ✅ | ✅ | +| Neon | ❌ | ✅ | ✅ | ✅ | +| AWS RDS | ✅ | ✅ | ✅ | ✅ | -Pulse primarily interfaces with a database's write-ahead log (Postgres) or binlog (MySQL) to efficiently capture data change events, offering a more performant solution than regular polling through scheduled queries. Note that Pulse may not work with every Postgres-compatible database, as compatibility depends on the exposure of Postgres-native logical replication capabilities required for change data capture. +## Does Pulse store my database events? - +Pulse does not persist database events and does not provide delivery guarantees regarding ordering or exact-once/at-least-once delivery. +To capture database events, an application must maintain an active connection to Pulse using the subscribe method. Any events occurring without an active subscription will be discarded. -Pulse’s database compatibility list will be different from Prisma Client's database compatibility list. If you want to use Pulse with an existing Prisma application, please verify the database and hosting provider are supported by Pulse. +## How can I increase the throughput for Prisma Pulse? - +Throughput for Prisma Pulse will increase as the Database event size decreases and the number of concurrent listeners decreases. + +While ensuring Database event size can be tricky, we recommend some best practices, such as: + +- Avoid large fields in your model, such as storing base64 image strings in the database; Instead, consider storing them in popular file storage options such as AWS S3 or Cloudflare. +- Creating publication slots for specific models rather than all the models in the database. You can learn more about managing your replication slots [here](/pulse/database-setup/general-database-instructions#max_replication_slots). +- Upgrading to use modern versions of PostgreSQL due to performance optimizations. + > ℹ️ Modern versions of PostgreSQL (`v15`+) allow you to create a publication slot for specific fields of a particular model. + +## Can I use Pulse in my front-end code? + +No, Pulse is server-side and subscriptions cannot be initiated directly within client-side code. If you would find this feature valuable, please share your thoughts on the `#help-and-questions` channel in our community [Discord](https://pris.ly/discord). diff --git a/content/400-pulse/700-feedback.mdx b/content/400-pulse/700-feedback.mdx index defdda8d95..8fe9bf14bf 100644 --- a/content/400-pulse/700-feedback.mdx +++ b/content/400-pulse/700-feedback.mdx @@ -1,13 +1,13 @@ --- title: 'Feedback' -metaTitle: 'Pulse: Feedback' -metaDescription: 'Learn where to submit feedback about Pulse.' +metaTitle: 'Prisma Pulse: Feedback' +metaDescription: 'Learn where to submit feedback about Prisma Pulse.' tocDepth: 3 toc: true --- -You can submit any feedback about Pulse in the [#pulse-feedback](https://prisma.slack.com/archives/C058GKE3C1E) channel in our community Slack. +You can submit any feedback about Prisma Pulse in the `#help-and-questions` channel in our community [Discord](https://pris.ly/discord). diff --git a/content/400-pulse/images/add-group.png b/content/400-pulse/images/add-group.png new file mode 100644 index 0000000000..083ac2897d Binary files /dev/null and b/content/400-pulse/images/add-group.png differ diff --git a/content/400-pulse/images/aws-rds-create-parameter-group.png b/content/400-pulse/images/aws-rds-create-parameter-group.png new file mode 100644 index 0000000000..20e969cb77 Binary files /dev/null and b/content/400-pulse/images/aws-rds-create-parameter-group.png differ diff --git a/content/400-pulse/images/pulse-usecase.png b/content/400-pulse/images/pulse-usecase.png new file mode 100644 index 0000000000..2bc05b4742 Binary files /dev/null and b/content/400-pulse/images/pulse-usecase.png differ diff --git a/content/400-pulse/images/railway-database-url.png b/content/400-pulse/images/railway-database-url.png new file mode 100644 index 0000000000..565c9eab05 Binary files /dev/null and b/content/400-pulse/images/railway-database-url.png differ diff --git a/content/400-pulse/images/railway-template-configure.png b/content/400-pulse/images/railway-template-configure.png new file mode 100644 index 0000000000..a190ef7936 Binary files /dev/null and b/content/400-pulse/images/railway-template-configure.png differ diff --git a/content/400-pulse/images/replication-slot-submission.png b/content/400-pulse/images/replication-slot-submission.png new file mode 100644 index 0000000000..7815f39f95 Binary files /dev/null and b/content/400-pulse/images/replication-slot-submission.png differ diff --git a/content/400-pulse/images/set-logical-replication-parameter.png b/content/400-pulse/images/set-logical-replication-parameter.png new file mode 100644 index 0000000000..451aa42ab0 Binary files /dev/null and b/content/400-pulse/images/set-logical-replication-parameter.png differ diff --git a/content/400-pulse/images/supabase-direct-database-connection.png b/content/400-pulse/images/supabase-direct-database-connection.png new file mode 100644 index 0000000000..c7cbf59ab2 Binary files /dev/null and b/content/400-pulse/images/supabase-direct-database-connection.png differ diff --git a/content/400-pulse/images/what-is-pulse.png b/content/400-pulse/images/what-is-pulse.png new file mode 100644 index 0000000000..8443201104 Binary files /dev/null and b/content/400-pulse/images/what-is-pulse.png differ diff --git a/content/500-platform/300-platform-console/10-about.mdx b/content/500-platform/10-about.mdx similarity index 100% rename from content/500-platform/300-platform-console/10-about.mdx rename to content/500-platform/10-about.mdx diff --git a/content/500-platform/300-platform-console/20-concepts/10-workspaces.mdx b/content/500-platform/20-concepts/10-workspaces.mdx similarity index 100% rename from content/500-platform/300-platform-console/20-concepts/10-workspaces.mdx rename to content/500-platform/20-concepts/10-workspaces.mdx diff --git a/content/500-platform/300-platform-console/20-concepts/20-projects.mdx b/content/500-platform/20-concepts/20-projects.mdx similarity index 58% rename from content/500-platform/300-platform-console/20-concepts/20-projects.mdx rename to content/500-platform/20-concepts/20-projects.mdx index 7af0f03a13..777fff1be9 100644 --- a/content/500-platform/300-platform-console/20-concepts/20-projects.mdx +++ b/content/500-platform/20-concepts/20-projects.mdx @@ -11,7 +11,3 @@ toc: true Projects embody your applications integrated with our products. Each project is associated with a Workspace and can be configured independently from one another.
- -## API Keys - -A project API key is required to authenticate requests from your Prisma Client to products such as Accelerate and Pulse. You may generate multiple API keys per project and manage those via the **Settings** tab of a project's page. diff --git a/content/500-platform/20-concepts/30-environments.mdx b/content/500-platform/20-concepts/30-environments.mdx new file mode 100644 index 0000000000..cb19c3148d --- /dev/null +++ b/content/500-platform/20-concepts/30-environments.mdx @@ -0,0 +1,39 @@ +--- +title: 'Environments' +metaTitle: 'Platform Environments' +metaDescription: 'Learn about Environments in Platform Console.' +tocDepth: 3 +toc: true +highlight: false +--- + + + +We're introducing Environments as a key component designed to enhance the way teams build, test, and grow their applications. + +By providing isolated spaces within each project, environments ensure that your development processes are agile and interference-free, allowing for more focused and productive team collaboration. + + + +## Building intuitive development workflows with environments + +Each Environment serves as an isolated space, enabling teams to build, test, and grow their projects across different stages of the development lifecycle. From initial experimentation to final production, environments facilitate a seamless progression of project development. + +## Limits + +| | Starter | Pro | Business | Enterprise | +| ---------------- | ----------- | ----------- | ------------ | ---------- | +| **Projects** | 5 | 10 | 15 | Custom | +| **Environments** | 2 / project | 6 / project | 12 / project | Custom | + +Visit Prisma Data Platform's [pricing page](https://pris.ly/pricing?utm_source=prisma-docs&utm_medium=docs-site) to learn more. + +## Leveraging the Prisma CLI for programmatic access + +The Prisma CLI enhances our platform by offering developers programmatic access to manage their environments efficiently. Ideal for integrating into CI workflows, the CLI allows for automating tasks such as configuring Prisma Accelerate or Prisma Pulse directly from the terminal. + +Read more about the Prisma CLI [here](/platform/platform-cli). + +## API Keys + +An API key is required to authenticate requests from your Prisma Client to products such as Prisma Accelerate and Prisma Pulse. You may generate multiple API keys per environment and manage those via the **API Keys** section in a project. diff --git a/content/500-platform/300-platform-console/20-concepts/index.mdx b/content/500-platform/20-concepts/index.mdx similarity index 100% rename from content/500-platform/300-platform-console/20-concepts/index.mdx rename to content/500-platform/20-concepts/index.mdx diff --git a/content/500-platform/300-platform-console/30-maturity-levels.mdx b/content/500-platform/30-maturity-levels.mdx similarity index 100% rename from content/500-platform/300-platform-console/30-maturity-levels.mdx rename to content/500-platform/30-maturity-levels.mdx diff --git a/content/500-platform/300-platform-console/40-limits.mdx b/content/500-platform/40-limits.mdx similarity index 100% rename from content/500-platform/300-platform-console/40-limits.mdx rename to content/500-platform/40-limits.mdx diff --git a/content/500-platform/300-platform-console/50-support.mdx b/content/500-platform/50-support.mdx similarity index 100% rename from content/500-platform/300-platform-console/50-support.mdx rename to content/500-platform/50-support.mdx diff --git a/content/500-platform/60-platform-cli/10-about.mdx b/content/500-platform/60-platform-cli/10-about.mdx new file mode 100644 index 0000000000..ac076f1513 --- /dev/null +++ b/content/500-platform/60-platform-cli/10-about.mdx @@ -0,0 +1,13 @@ +--- +title: 'About' +metaTitle: 'Platform CLI: About' +tocDepth: 3 +--- + + + +This guide demonstrates how to access the Prisma Data Platform using the [Prisma CLI](/orm/tools/prisma-cli). Get started by ensuring you have the Prisma CLI installed, following our setup [instructions](/orm/tools/prisma-cli#installation). + +This integration, now in Early Access, expands the capabilities of the Prisma CLI, enabling management of your Platform projects directly from the command line. For a detailed overview of all the commands, please refer to the [Commands page](/platform/platform-cli/commands). + + diff --git a/content/500-platform/60-platform-cli/20-commands.mdx b/content/500-platform/60-platform-cli/20-commands.mdx new file mode 100644 index 0000000000..7f55dd5051 --- /dev/null +++ b/content/500-platform/60-platform-cli/20-commands.mdx @@ -0,0 +1,311 @@ +--- +title: 'Commands' +metaTitle: 'Platform CLI: Commands' +tocDepth: 4 +--- + + + +This document describes the Prisma Data Platform's integrated Prisma CLI commands, arguments, and options. + + + +## Getting started + +To get started, ensure you have the [Prisma CLI](/orm/tools/prisma-cli) updated to version `5.10.0` or later. This is necessary to access the Platform through the Prisma CLI. + + + +💡 When using commands, always start with `prisma platform` and include the `--early-access` flag to enable the use of the Prisma Data Platform whilst still in early access. + + + +## Authentication + +### platform + +#### auth login + +Opens a browser window that allows you to log into your Prisma Data Platform account or create a new one. + +```bash +npx prisma platform auth login --early-access +``` + +#### auth logout + +Logs out of your Prisma Data Platform account. + +```bash +npx prisma platform auth logout --early-access +``` + +#### auth show + +Displays information about the currently authenticated user. + +```bash +npx prisma platform auth show --early-access +``` + +### Workspace Management + +### platform + +#### workspace show + +Lists all workspaces available to your account. + +```bash +npx prisma platform workspace show --early-access +``` + +### Project Management + +### platform + +#### project show + +Lists all projects within the specified workspace. + +```bash +npx prisma platform project show \ +--workspace $INSERT_WORKSPACE_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ------------------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------- | +| `--workspace` `-w` | `string` | yes | The workspace id.

**Hint:** You can view your workspace ids with the [`workspace show`](#workspace-show) command. | + +#### project create + +Creates a new project within the specified workspace. + +```bash +npx prisma platform project create \ +--workspace $INSERT_WORKSPACE_ID \ +--name "INSERT_PROJECT_NAME" \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ------------------ | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- | +| `--workspace` `-w` | `string` | yes | The workspace `id`.

**Hint:** You can view your workspace ids with the [`workspace show`](#workspace-show) command. | +| `--name` `-n` | `string` | no | The display name for the project.

If omitted, a default project name will be generated for you. | + +#### project delete + +Deletes the specified project. + +```bash +npx prisma platform project delete \ +--project $INSERT_PROJECT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ---------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- | +| `--project` `-p` | `string` | yes | The project `id`.

**Hint:** You can view your project ids with the [`project show`](#project-show) command. | + +### Environment Management + +### platform + +#### environment show + +Lists all environments within the specified project. + +```bash +npx prisma platform environment show \ +--project $INSERT_PROJECT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ---------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------------------- | +| `--project` `-p` | `string` | yes | The project `id`.

**Hint:** You can view your project ids with the [`project show`](#project-show) command. | + +#### environment create + +Creates a new environment within the specified project. + +```bash +npx prisma platform environment create \ +--project $INSERT_PROJECT_ID \ +--name $INSERT_ENVIRONMENT_NAME \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ---------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- | +| `--project` `-p` | `string` | yes | The project `id`.

**Hint:** You can view your project ids with the [`project show`](#project-show) command. | +| `--name` `-n` | `string` | no | The display name for the environment.

If omitted, a default environment name will be generated for you. | + +#### environment delete + +Deletes the specified environment. + +```bash +npx prisma platform environment delete \ +--environment $INSERT_ENVIRONMENT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | + +### API Key Management + +### platform + +#### apikey show + +Lists all API keys for the specified environment. + +```bash +npx prisma platform apikey show \ +--environment $INSERT_ENVIRONMENT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | + +#### apikey create + +Creates a new API key for the specified project. + +```bash +npx prisma platform apikey create \ +--environment $INSERT_ENVIRONMENT_ID \ +--name $INSERT_API_KEY_NAME \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | +| `--name` `-n` | `string` | no | The display name for the API key.

If omitted, a default API key name will be generated for you. | + +#### apikey delete + +Deletes the specified API Key. + +```bash +npx prisma platform apikey delete \ +--apikey $INSERT_API_KEY_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------ | +| `--apikey` | `string` | yes | The API key `id`.

**Hint**: You can view your API key ids with the [`apikey show`](#apikey-show) command. | + +### Prisma Accelerate + +### platform + +#### accelerate enable + +Enables Prisma Accelerate for the specified environment. + +```bash +npx prisma platform accelerate enable \ +--environment $INSERT_ENVIRONMENT_ID \ +--url "postgresql://username:password@host:port/database" \ +--region $INSERT_CONNECTION_POOL_REGION \ +--apikey true \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | +| `--url` | `string` | yes | Your database connection string. | +| `--region` | `string` | no | The region for Prisma Accelerate’s managed connection pool.

View the list of available regions [here](/accelerate/faq#what-regions-is-accelerates-connection-pool-available-in).

**Hint**: Select the region _nearest_ your database for optimal latency. | +| `--apikey` | `boolean` | no | If yes, a new API key will be generated for the associated environment. | + +#### accelerate disable + +Disables Prisma Accelerate for the specified environment. + +```bash +npx prisma platform accelerate disable \ +--environment $INSERT_ENVIRONMENT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | + +### Prisma Pulse + +### platform + +#### pulse enable + +Enables Prisma Pulse for the specified environment. + +```bash +npx prisma platform pulse enable \ +--environment $INSERT_ENVIRONMENT_ID \ +--url "postgresql://username:password@host:port/database" \ +--region $INSERT_REGION \ +--apikey true \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | +| `--url` | `string` | yes | Your database connection string. | +| `--region` | `string` | no | The region for Prisma Pulse. | +| `--apikey` | `boolean` | no | If yes, a new API key will be generated for the associated environment. | + +#### pulse disable + +Disables Prisma Pulse for the specified environment. + +```bash +npx prisma platform pulse disable \ +--environment $INSERT_ENVIRONMENT_ID \ +--early-access +``` + +##### Arguments + +| Argument | Type | Required | Description | +| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| `--environment` `-e` | `string` | yes | The environment `id`.

**Hint:** You can view your environment ids with the [`environment show`](#environment-show) command. | + +## Help + +Have a question? Let us know, we’re here to help. Reach out to us on [Discord](https://pris.ly/discord). diff --git a/content/500-platform/300-platform-console/index.mdx b/content/500-platform/60-platform-cli/index.mdx similarity index 53% rename from content/500-platform/300-platform-console/index.mdx rename to content/500-platform/60-platform-cli/index.mdx index de65157629..10845e4817 100644 --- a/content/500-platform/300-platform-console/index.mdx +++ b/content/500-platform/60-platform-cli/index.mdx @@ -1,6 +1,8 @@ --- -title: 'Platform Console' +title: 'Platform CLI' +metaTitle: 'Platform CLI' staticLink: true +earlyaccess: true --- diff --git a/content/500-platform/600-classic-projects/050-data-proxy/100-use-data-proxy.mdx b/content/500-platform/600-classic-projects/050-data-proxy/100-use-data-proxy.mdx deleted file mode 100644 index 64ffc509c7..0000000000 --- a/content/500-platform/600-classic-projects/050-data-proxy/100-use-data-proxy.mdx +++ /dev/null @@ -1,249 +0,0 @@ ---- -title: 'Use Data Proxy' -metaTitle: 'Configure Data Proxy for your database application' -metaDescription: 'To use the Data Proxy for a JavaScript/TypeScript application that uses Prisma, you must first create a project in Prisma Data Platform. When you create the project, you select a Data Proxy region and create a Data Proxy connection string. You start to use the Data Proxy, when you replace the direct database connection string with the Data Proxy one.' -tocDepth: 2 ---- - - - -To use the Data Proxy for a JavaScript/TypeScript application that uses Prisma, you must first create a project in Prisma Data Platform. When you create the project, you do the following: - -- select a Data Proxy region for the project (make sure that it is close to your database) -- create a Data Proxy connection string - - - -**Note**

- -When you create your project, you do not need to also create a Data Proxy connection string. You can always create a new Data Proxy connection string at a later time as described below in [Enable Data Proxy for a project](#enable-the-data-proxy-for-a-project). - -
- -You can then configure the connection string in your development or deployment environment and [configure Prisma project to use Data Proxy](#configure-prisma-project-to-use-data-proxy). - -
- -## Enable the Data Proxy for a project - -When you create a project in the platform, the Data Proxy is automatically enabled for your project. - - - -**Note**

- -The fact that the Data Proxy is enabled for a project does not yet mean that your application starts to use the proxy.

- -Your application starts to use the proxy only after you configure a generated Data Proxy connection string as an environment variable for your project so that Prisma Client uses the proxy connection string and not the direct connection to the database. - -
- -### Prerequisites - -- Create a project to add your application in the platform. During the process, select a geographic location for the Data Proxy that is closest to the location of your database. -- If your database is behind a firewall, enable static IP addresses for your project and add the IP addresses for the selected Data Proxy region to the allowlist of your database. - - US East 1 (West Virginia) - - 54.204.197.119 - - 3.222.148.224 - - 54.204.47.202 - - 3.227.136.248 - - EU Central 1 (Frankfurt, Germany) - - 35.157.74.165 - - 18.194.25.248 - - 18.184.112.103 - - 18.157.219.25 - -### Steps - -1. Open your project in the Prisma Data Platform. You can do so from the [**Projects**](https://cloud.prisma.io/projects) page. -2. Get a Data Proxy connection string for the selected environment. - - 1. With the project open and an environment selected, click the **Data Proxy** tab. - 2. Click **Create a connection string**. - - - - **Note**

- - You can generate as many Data Proxy connection strings as you need. You can later revoke any of the connection strings that you no longer need. - -
- - 3. Enter a name for the new Data Proxy connection string and click **Create**. - - Prisma Data Platform - Data Proxy - Create and name a new Data Proxy connection string - - 4. Copy the `prisma://` connection string. - - - - **Important**

- - Save the `prisma://` connection string securely. After you navigate to another page, you cannot retrieve the connection string again from the **Data Proxy**. You can only generate a new connection string, if necessary. - -
- - Prisma Data Platform - Data Proxy - Copy the Data Proxy connection string - -## Configure Prisma project to use Data Proxy - -After you create your project in the platform and enable the Data Proxy, you can generate Prisma Client for the Data Proxy and use it with the `prisma://` connection string you obtained. - -You can generate and use Prisma Client for the Data Proxy in the following environments: - -- In your local development environment, to test the process. -- In your deployment platform. You must replace the direct database connection string with the Data Proxy connection string and make sure that Prisma Client is auto-generated with the `--data-proxy` flag as described below. - -### Prerequisites - -- [Enable Data Proxy for your project](#enable-the-data-proxy-for-a-project). -- Copy the Data Proxy connection string. Do so for the project environment for which you want to generate Prisma Client. - -### Steps - -1. In your local development environment, replace the direct database connection string with the Data Proxy `prisma://` connection string. - - ```bash file=.env highlight=1;delete|2;add - - DATABASE_URL="postgresql://****:****@****" - + DATABASE_URL="prisma://****:****@****" - ``` - - - - **Note**

- For security reasons, use environment variables for database connection strings and Data Proxy strings. Do not hard-code them into `schema.prisma`. For more information, see [Using `.env` files](/orm/more/development-environment/environment-variables/env-files). - -
- -1. To introspect your database or perform migrations using the Prisma CLI, a direct database connection is required. If you are using Prisma version 4.1.0 or later, include the `directUrl` property in the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block of your Prisma schema. - - ```prisma file=schema.prisma highlight=8;add - generator client { - provider = "prisma-client-js" - } - - datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - directUrl = env("DIRECT_URL") - } - ``` - - Then, add the direct database connection string in the `.env` file. - - ```bash file=.env highlight=2;add - DATABASE_URL="prisma://****:****@****" - +DIRECT_URL="postgresql://****:****@****" - ``` - - However, in older versions, you need to overwrite the `DATABASE_URL` environment variable with the direct database connection string when running migrations. Refer to the Prisma CLI commands with the Data Proxy documentation for more information. - -1. Install `prisma` and `@prisma/client`.

- Make sure to use version 3.15.2 or later.
- - ```terminal - npm install prisma@latest --save-dev - npm install @prisma/client@latest --save - ``` - -1. Generate Prisma Client with the `--data-proxy` option. - - ```terminal - npx prisma generate --data-proxy - ``` - - The generated Prisma Client is a lightweight version because it excludes the local [query engine](/orm/more/under-the-hood/engines) files. The Data Proxy handles the query engine logic. - -1. Instantiate Prisma Client in your application code. - - - To use the Data Proxy with Node.js, instantiate `@prisma/client`. [Learn more](/orm/prisma-client/setup-and-configuration/generating-prisma-client). - - , ]}> - - - - ```ts - import { PrismaClient } from '@prisma/client' - const prisma = new PrismaClient() - // use `prisma` in your application to read and write data in your DB - ``` - - - - - - ```js - const { PrismaClient } = require('@prisma/clientj') - const prisma = new PrismaClient() - // use `prisma` in your application to read and write data in your DB - ``` - - - - - - - To use the Data Proxy in Edge runtimes, such as Cloudflare Workers or Vercel Edge Functions, instantiate `@prisma/client/edge`. - - - - **Note**

- - You can use `@prisma/client/edge` only with the Data Proxy. In such cases, make sure to use the `--data-proxy` flag or the `PRISMA_GENERATE_DATAPROXY=true` environment variable when you [generate Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client). - -
- - , ]}> - - - - ```ts - import { PrismaClient } from '@prisma/client/edge' - const prisma = new PrismaClient() - // use `prisma` in your application to read and write data in your DB - ``` - - - - - - ```js - const { PrismaClient } = require('@prisma/client/edge') - const prisma = new PrismaClient() - // use `prisma` in your application to read and write data in your DB - ``` - - - - - -### Result - -Your application now uses the Data Proxy. - -The generated Prisma Client has a reduced bundle size because the entire query engine logic is now hosted with the Data Proxy. - -## Manage the number of database connections - -You can set the maximum number of database connections per Data Proxy instance via the `connection_limit` argument in the database connection connection string that's provided to the PDP project via the PDP web UI. - -The _default_ value for the `connection_limit` in each Data Proxy instance is `5`. This default value is determined using the calculation `num_physical_cpus * 2 + 1`. The machines Data Proxy is running on have two CPUs, so: `2 * 2 + 1 = 5`. - -Here is a sample connection string for the Data Proxy connection that uses the `connection_limit` argument: - -``` -postgresql://USER:PASSWORD@HOST:PORT/DB?connection_limit=10 -``` - -In the example connection string, the connection limit of `10` is used as a sample value. To ensure that your database's connections are not exhausted, it is recommended to set an appropriate value for the connection limit. This will help manage the surge in traffic effectively and prevent any connection-related issues. - -It's important to understand that this connection limit applies to each individual QE instance. For example, if the `connection_limit` is set to `10` and `5` Query Engine (QE) instances are created, a total of `50` connections would be established with the database (`connection_limit * QE instances`). It is important to ensure that the database has sufficient capacity to handle this load of `50` connections. - -For more detailed information regarding the limits of the Data Proxy and its concurrency limits, we recommend referring to the Concurrency Limits documentation. diff --git a/content/500-platform/600-classic-projects/050-data-proxy/500-deploy.mdx b/content/500-platform/600-classic-projects/050-data-proxy/500-deploy.mdx deleted file mode 100644 index 083a2018c0..0000000000 --- a/content/500-platform/600-classic-projects/050-data-proxy/500-deploy.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: 'Deploy with the Data Proxy' -metaTitle: 'Deploy with the Data Proxy' -metaDescription: 'Deploy with the Data Proxy' ---- - -## Deploy to Vercel Serverless Functions - -To start using the Data Proxy, you only need minimal changes to an existing project that is based on Prisma Client with [Vercel Serverless Functions](https://vercel.com/docs/concepts/functions#serverless-functions). - -Our Vercel Deployment sample repository has a [special branch](https://github.com/prisma/deployment-example-vercel/tree/data-proxy) that shows how to deploy a Prisma application to Vercel Serverless Functions with the Data Proxy. -[Use this link to create a Vercel project based on this branch](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fprisma%2Fdeployment-example-vercel%2Ftree%2Fdata-proxy&env=DATABASE_URL,MIGRATE_DATABASE_URL,PRISMA_GENERATE_DATAPROXY&envDescription=DATABASE_URL%20-%20Data%20Proxy%20URL%2C%20MIGRATE_DATABASE_URL%20-%20direct%20connection%20string%2C%20PRISMA_GENERATE_DATAPROXY%20-%20always%20set%20to%20true%20so%20Vercel%20generates%20a%20Data%20Proxy%20Client&envLink=https%3A%2F%2Fwww.prisma.io%2Fdocs%2Fconcepts%2Fdata-platform%2Fdata-proxy%23using-the-data-proxy-in-a-prisma-application). The link makes sure that you set the correct environment variables to get a Prisma Client for Data Proxy and run migrations when you configure Data Proxy. - -If you want to adapt your project manually: - -- Add the environment variable `PRISMA_GENERATE_DATAPROXY` to your [Vercel project settings](https://vercel.com/docs/concepts/projects/environment-variables) and set its value to `true`. -- If you want to deploy migrations to your project in Vercel, follow our instructions on how to use Prisma CLI with the Data Proxy. - -## Deploy to Cloudflare Workers - -You can use the Data Proxy to deploy Prisma projects to Cloudflare Workers. To learn more, see [Deploy to Cloudflare Workers guide](/orm/prisma-client/deployment/edge/deploy-to-cloudflare-workers). diff --git a/content/500-platform/600-classic-projects/050-data-proxy/700-prisma-cli-with-data-proxy.mdx b/content/500-platform/600-classic-projects/050-data-proxy/700-prisma-cli-with-data-proxy.mdx deleted file mode 100644 index 140525dc5a..0000000000 --- a/content/500-platform/600-classic-projects/050-data-proxy/700-prisma-cli-with-data-proxy.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: 'Prisma CLI commands with the Data Proxy' -metaTitle: 'Use Prisma Migrate and Introspect with the Data Proxy' -metaDescription: 'Currently, you can use Prisma Client with the Data Proxy only to query your database. If you want to run Prisma Migrate or Introspect, or any of the Prisma CLI commands listed below, you can only do so on a direct (non-Data Proxy) database connections.' -tocDepth: 4 ---- - - - -Currently, you can only use [Prisma Client](/orm/prisma-client) with the Data Proxy to _query_ your database. - -When using Prisma CLI, you need a direct (non-Data Proxy) database connection if you apply schema changes to your database with [Prisma Migrate](/orm/prisma-migrate/getting-started) or [`db push`](/orm/prisma-migrate/workflows/prototyping-your-schema), or if you [introspect](/orm/prisma-schema/introspection) your database. See [Prisma CLI commands that require a direct database connection](#prisma-cli-commands-that-require-a-direct-database-connection). - -In Prisma versions 4.10.0 and later, you can [set a direct database connection URL in your Prisma schema](#set-a-direct-database-connection-url-in-your-prisma-schema). - -In earlier versions, you must add an [environment variable](/orm/more/development-environment/environment-variables) with the direct database connection URL and overwrite the [`DATABASE_URL` environment variable](/orm/more/development-environment/environment-variables/env-files#example-set-the-database_url-environment-variable-in-an-env-file) when you need a direct connection. - - - -## Prisma CLI commands that require a direct database connection - -The following [Prisma CLI commands](/orm/reference/prisma-cli-reference) require a direct connection: - -- `prisma db pull` -- `prisma migrate deploy` -- `prisma migrate dev` -- `prisma migrate diff` (some parameters only) -- `prisma migrate reset` -- `prisma migrate resolve` -- `prisma migrate status` -- `prisma db push` -- `prisma db drop` -- `prisma db execute` -- `prisma studio` (supported from version [`5.1.0`](https://github.com/prisma/prisma/releases/tag/5.1.0) upwards) - -## Set a direct database connection URL in your Prisma schema - -To provide a URL for a direct database connection, set the `directUrl` property in the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block of your Prisma schema: - -```prisma file=schema.prisma highlight=8;add -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - directUrl = env("DIRECT_URL") -} -``` - -Then add the `DIRECT_URL` environment variable to your [`.env` file](/orm/more/development-environment/environment-variables/env-files): - -```env file=.env highlight=4-5;add -# Connection to Prisma Data Proxy. Used by Prisma Client. -DATABASE_URL="prisma://__HOST__/?api_key=__KEY__" - -# Connection to the database. Used for migrations and introspection. -DIRECT_URL="postgresql://__USER__:__PASSWORD__@__HOST__:__PORT__/__DATABASE__" -``` diff --git a/content/500-platform/600-classic-projects/050-data-proxy/900-considerations-limitations.mdx b/content/500-platform/600-classic-projects/050-data-proxy/900-considerations-limitations.mdx deleted file mode 100644 index c8ff88d881..0000000000 --- a/content/500-platform/600-classic-projects/050-data-proxy/900-considerations-limitations.mdx +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: 'Data Proxy considerations and limitations' -metaTitle: 'Data Proxy considerations and limitations' -metaDescription: 'When you use the Data Proxy for applications in serverless and edge runtimes, bear in mind a few considerations and learn about the current limitations.' -tocDepth: 4 ---- - -## Considerations - -### Connect to databases hosted with a provider different from AWS - -You can connect to a database hosted on any provider that is accessible from a public internet address. For best results and response times, configure Data Proxy in a region that is the same or as close as possible to the database. - -We plan to expand the number of providers and regions. If we don't yet support a region or provider, you can [submit a request](https://pris.ly/proxy-new-region). This helps us to prioritize providers and regions. - -### Recommended concurrent connections - -We recommend that you use a database that supports at least 20 concurrent connections. - -You will probably not need to set a concurrency limit on AWS Lambda. If necessary, requests are queued until they can be processed. - -For more information about configuring a maximum number of connections to the database, see [Manage the number of database connections](/platform/classic-projects/data-proxy/use-data-proxy#manage-the-number-of-database-connections). - -### Idle connections to the database - -The Data Proxy keeps several connection pools running to maintain open database connections even when your application does not run any queries. The connection pools and any remaining idle connections close after six minutes of inactivity (or when your application does not send any queries to the database). The number of idle connections to the database depends on the number of running connection pools at any point in time. - -In each of the supported locations, the Data Proxy architecture includes multiple clusters that maintain idle connections to the database. - -## Limitations - -### Prisma Migrate and Introspection do not work with a Data Proxy connection string - -You cannot use specific Prisma CLI commands, such as `prisma migrate` and `prisma db pull` with a Data Proxy connection string. - -To work around this issue, [specify a direct database connection string for each Prisma CLI command](/platform/classic-projects/data-proxy/prisma-cli-with-data-proxy) that you need. - -### Data Proxy concurrency limits - -Depending on your project plan, the Prisma Data Proxy provides a different limit of concurrent proxy instances. - -The performance of a single proxy instance depends on a large number of variables, including the following: - -- the type of queries -- latencies and deployment locations -- the performance of your database - -If you see `429` HTTP errors in your logs, this probably means that you hit the concurrency limits. - -[Contact Support](/platform/classic-projects/support) if you hit the concurrency limits and cannot scale your Prisma application. - -### Unsupported Prisma Client features - -#### Metrics preview feature not supported - -Data Proxy does not yet support Prisma Client's [Metrics](/orm/prisma-client/observability-and-logging/metrics) preview feature. - -To use the Data Proxy, you must first remove `metrics` from the `previewFeatures` section of your `schema.prisma` file. - -For example: - -```diff - generator client { - provider = "prisma-client-js" -- previewFeatures = ["metrics"] -+ previewFeatures = [] - } -``` - -If you have the `metrics` preview feature enabled and you run `prisma generate --data-proxy`, the command shows an error. - -#### $connect and $disconnect not supported - -With the Data Proxy, the `PrismaClient` method `$connect` does not create a new connection pool and the `$disconnect` method does not close the connection pool. - -Both methods are valid syntax in Prisma Client with the Data Proxy, but they do not have any impact on the connections to the database. This is because the Data Proxy manages the connections. diff --git a/content/500-platform/600-classic-projects/050-data-proxy/index.mdx b/content/500-platform/600-classic-projects/050-data-proxy/index.mdx deleted file mode 100644 index d9795aebca..0000000000 --- a/content/500-platform/600-classic-projects/050-data-proxy/index.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: 'Data Proxy' -metaTitle: 'Data Proxy' -metaDescription: 'Data Proxy in the Prisma Data Platform provides database connection management and pooling, load balancing, scaling, and fault tolerance features so that you can manage and scale database connections for applications that use Prisma ORM. With Data Proxy, your application can scale and maintain predictable database performance because it also limits the total number of database connections.' -tocDepth: 3 ---- - - - -Serverless functions are ephemeral and short-lived, so their database connections are numerous and brief. Because of this, using traditional databases in serverless environments often leads to the exhaustion of the maximum number of concurrent database connections and increased latencies when each request needs to establish a database connection. - -The Data Proxy in Prisma Data Platform provides database connection management and pooling, load balancing, scaling, and fault tolerance so that you can manage and scale database connections for applications that run with Prisma ORM in serverless environments. With the Data Proxy, your application can scale and maintain predictable database performance because it also limits the total number of database connections. - -Designed specifically with serverless functions in mind, the Data Proxy provides a wide range of benefits for applications that run in serverless and edge environments. - - - -## Architecture - -Prisma develops and maintains the Data Proxy infrastructure and services to provide capabilities that your database application needs to scale when you run your application in serverless and edge environments. - -Data Proxy infrastructure is currently available in two regions: - -- US East 1 (West Virginia, United States) -- EU Central 1 (Frankfurt, Germany) - - - -**Request a new Data Proxy region**

- -If you want us to make the Data Proxy available in a new region, you can submit your request [here](https://prisma103696.typeform.com/to/Y03RBE5c). - -
- -In each region, the Data Proxy infrastructure has multiple clusters that enable the load balancing, high availability, and failover of database connection pooling and management. - -You can use Data Proxy with [all databases that Prisma ORM supports](/orm/reference/supported-databases). - -## Connection pooling and connection management - -Data Proxy provides connection pooling so that your application can reuse active connections and never exhaust the maximum number of connections that your database allows. - -Connection pooling with the Data Proxy utilizes orchestrated Prisma [query engine](/orm/more/under-the-hood/engines) technology to open, maintain, and close connection pools. It helps applications load-balance and scale database requests based on demand. - -A Data Proxy connection pool maintains active database connections and ensures that an application reuses them when new requests come in. - -In each region, Data Proxy management services orchestrate the lifecycle of connection pools. The lifecycle of a Data Proxy connection pool goes through the following stages: - -- the assignment of connection pools from each available cluster in the region -- the increase of connection pools when the workload of your application increases -- the maintenance of idle connection pools -- the decrease and stop of connection pools after six minutes of inactivity in a pool - -This orchestration ensures that you accumulate Data Proxy usage (in CPU milliseconds) only when your database processes queries. - -The orchestration of Data Proxy connection pools ensures high availability, load balancing, and scalability of your application. - -- **High availability**. In each region, the Data Proxy infrastructure runs multiple clusters. By default, the Data Proxy starts a connection pool from each cluster and assigns each connection pool to your application. This remains valid until your application reaches higher workloads when the Data Proxy adds new connection pools as needed. If any of the clusters go through a period of downtime, the remaining ones take over the management of connection pools. - - - - **Note**

- - You can select only one of the available regions for an environment of your application in the Prisma Data Platform.

- - Because of this, the high availability of Data Proxy infrastructure applies inside a single region. Data Proxy connection pools from other regions cannot take over an application's connection pool from the current region. - -
- -- **Load balancing**. In each region, the number of incoming requests for an application is distributed between multiple connection pools running from the different clusters available in the region. -- **Scalability**. Data Proxy creates new connection pools during periods of higher activity and closes connection pools when they are no longer necessary. This orchestration provides the flexibility to scale your database application and allows for reduced costs at times of lower activity. - -## Reduced bundle size - -By default, Prisma Client bundles the query engine that includes the connection logic for all databases that Prisma supports. - -Prisma Client without the Data Proxy - -Data Proxy includes the query engine logic to connect and maintain connection pools. This means that when you generate Prisma Client to work with Data Proxy, your application bundle does not need to include the query engine logic. As a result, your application has a reduced bundle size, which speeds up load times and improves performance. - -Prisma Client with the Data Proxy - -## Faster cold starts - -With the Data Proxy and with a reduced bundle size, you achieve faster serverless cold starts. This is possible because the query engine logic is no longer included in the bundle size and because the Data Proxy keeps the existing database connections live on the remote Data Proxy and reuses them for new requests. - -## In this section - - diff --git a/content/500-platform/600-classic-projects/100-platform/060-static-ips.mdx b/content/500-platform/600-classic-projects/100-platform/060-static-ips.mdx deleted file mode 100644 index 01e0b6e6ab..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/060-static-ips.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: 'Static egress IP addresses' -metaTitle: 'Static egress IP addresses' -metaDescription: 'Learn about using static IP addresses with the Prisma Data Platform' ---- - - - -Most cloud database providers provide a way to restrict database access to a set of known origin public IP addresses. - - - -## About Static IP addresses - -You can use the static IP addresses feature to connect your databases to the Prisma Data Platform securely whilst keeping them protected from the public internet. - -When you implement static IP addresses for your database, then the platform will connect to your database using this static IP address. This works seamlessly across all features: data browser, query console, data proxy. - -The following database offerings are compatible with this feature: - -- AWS RDS via security groups -- AWS Aurora via [security groups](https://aws.amazon.com/premiumsupport/knowledge-center/aurora-mysql-connect-outside-vpc/) (not Aurora Serverless) -- [MongoDB Atlas](https://docs.atlas.mongodb.com/security/ip-access-list/) -- [Google Cloud SQL](https://cloud.google.com/sql/docs/mysql/configure-ip#add) - -The following database offerings are not compatible: - -- AWS Aurora Serverless (database does not have a public IP) - -## Important Considerations - -Before implementing static IP addresses, review the following considerations: - -- if the IP addresses are removed from the IP allow list on the database provider, the Prisma Data Platform will lose connectivity to the database -- the IP addresses are specific to the region in which the data proxy is configured. Changing the region of the data proxy will change the IPs for egress and will thus require a change of the IP allow list on your provider -- should Prisma ever change any of the public IPs used, we will communicate with impacted users - -## Enabling the static IP addresses feature - -There are different contexts in which the static IP feature can be configured: - -- when creating a new project, at the stage at which a database is configured -- when creating a new environment -- when updating the database settings of an existing environment - -#### Step 1. Enable the feature - -In the Prisma Data Platform, either when you are creating a new project or environment (or when modifying the settings of an existing environment), navigate to the Static IP addresses section. Select the option "Enabled (there is a firewall in front of my database)". - -A list of three (3) IP addresses display. - -#### Step 2. Allow traffic in your database provider - -In your database provider, configure your database to allow traffic from the IP addresses displayed in the previous step. Please make sure to include all three (3) addresses. - -#### Step 3. Save to test connectivity and finish - -Back in your Prisma Data Platform account, again in the Static IP addresses section, submit the form. At this point, the platform will verify that it can connect to the database. -If it cannot connect, it means something went wrong with the setup. Please review the configuration with your database provider. diff --git a/content/500-platform/600-classic-projects/100-platform/200-projects/100-create.mdx b/content/500-platform/600-classic-projects/100-platform/200-projects/100-create.mdx deleted file mode 100644 index 6fa40f5de1..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/200-projects/100-create.mdx +++ /dev/null @@ -1,256 +0,0 @@ ---- -title: 'Create a project' -metaTitle: 'Create a project in the Prisma Data Platform' -metaDescription: 'In the Prisma Data Platform, you can create a project from your JavaScript/TypeScript database application that uses Prisma. To do so, you need to have your database connection string at hand and configure access to the database from the Prisma Data Platform static IPs (if necessary) as well as select a Data Proxy region.' -tocDepth: 2 ---- - - - -In the Prisma Data Platform, you can create new projects with just a connection string for an available database. If your database sits behind a firewall or only allows connections from specific IPs, you can enable the use of static IPs of the platform and add them to your database allowlist. You can also select the [Data Proxy](/platform/classic-projects/data-proxy) region to prepare your project for connection pooling and load balancing in serverless environments. - -After you create your project, you can optionally link your Prisma schema (if you push it to a GitHub repository) so that we can keep your project in sync with its latest version. - -
- -Why should I link my Prisma schema and GitHub repository? - -The features in [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console) rely on an up-to-date schema that matches the latest data model in your database.

- -When you _create a project with an existing database_, the platform introspects your database and generates a Prisma schema for your project. If you make a change to your database model and the platform does not have a linked schema, you and your team might start seeing errors while you use [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console).

- -If you _create a project with an empty database_, [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console) remain inactive for the project because the database introspection cannot generate a Prisma schema from an empty database. - -
- -Later, if you want to enable connection pooling and load balancing of database connections with the Data Proxy, you can copy the Data Proxy connection string for the project. - -
- -## Create a project - -When you create a project, you only need a database connection string. - -### Prerequisites - -Copy the database connection string for your project. The platform uses the connection string only to read and introspect the database. - - - -**Note**

- -Check that the connection string meets the requirements listed below. - -- Use a [Prisma ORM-supported database](/orm/reference/supported-databases). -- The connection string must include `user` and `password` -- Use the connection string format below. - ```code no-copy - ://:@:/ - ``` - -
- -### Steps - -1. From the [**Projects**](https://cloud.prisma.io/projects/) page, click **New Project**. -2. In **Connection string**, paste the database connection string. -3. (Optional) From **Static IPs**, select **Enabled** if your database is behind a firewall and you can only configure external access from specific IP addresses. Copy the IP addresses and add them to the allowlist of your database. - - - - **Note**

- For more information, see Static egress IP address static-ips. - -
- -4. From **Choose a Data Proxy region**, select the geographic location for the Data Proxy. - - - - **Important**

- Select a Data Proxy location that is close to the geographic location of your database.

- If you select a location that is remote from your database, then when your application sends requests to your database through the Data Proxy, you might notice some delay in the responses. - -
- - After you create the project, you can [create a Data Proxy connection string](#optional-create-a-data-proxy-connection-string) and use that to set up connection pooling locally or in your deployment environment. - -5. Click **Create project**. - Prisma Data Platform - Create project - Paste database connection string, select Data Proxy region, enable static IPs - -### Result - -The platform creates your project and assigns it a random name, such as **Grey fish **, where **** is an auto-generated code. You can later change the project name from the project settings. - -#### If your database does not contain any models - -You see a notification that your database is empty. Because your database does not contain any models, the introspection cannot generate a Prisma schema. - -As a result, [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console) are inactive. You can start using them after you [enable Prisma schema synchronization](#optional-enable-schema-synchronization). - -#### If your database contains models - -The platform introspects the database to read the data models so that it can generate the Prisma schema. The Prisma schema enables the features in [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console), where you can edit and query your data. - -#### If introspection fails and can't generate a schema - -You will be prompted with a notification telling that your project was created but introspection failed. Introspection may fail if the database is unreachable or the process timeouts. In order to utilize the Data Browser or Query Console, a project must have a valid Prisma schema that matches with the provided database. - -Upon introspection failure, you will be taken to a "Provide schema" view, where you can [provide a schema](#optional-provide-a-schema) by either linking a schema from a repository or upload your schema. - -### What's next - -- Click **Skip and continue to Data Platform** to go to **Data Browser** for your project.

- If your database is empty, you are redirected to **Schema Viewer** where you can optionally provide a GitHub repository with your Prisma schema to set up schema synchronization. -- If introspection fails, you can remain on the **Provide a schema** screen and complete project setup - - [(Optional) Provide a schema](#optional-provide-a-schema) -- Alternatively, remain on the **Get started** screen and complete the optional configurations for your project. - - [(Optional) Enable Prisma schema synchronization](#optional-enable-schema-synchronization) - - [(Optional) Create a Data Proxy connection string](#optional-create-a-data-proxy-connection-string) - -## (Optional) Provide a schema - -After you create a project but introspection fails, you can provide a schema on the **Provide a schema** screen. You can provide a schema by either linking a schema from a repository or uploading your schema file - -You can link a schema from a repository to keep your project's Prisma schema and data models in **Data Browser** and **Query Console** updated with the latest version of your Prisma schema. - -#### Link a schema from a repository - -Steps: - -1. On the **Link a schema from a repository** section, from **GitHub Account**, select a GitHub account or organization. -2. From **Repository**, select the GitHub repository you want to import. -3. From **Branch**, select the branch you want to import. -4. In **Prisma schema path**, enter the path to the `schema.prisma` file. - - - - **Note**

- - The pre-filled path `prisma/schema.prisma` is the default path. Change it to the path you use for your project. - -
- -5. Click **Link Prisma schema**.
- Prisma Data Platform - Create project - Link a schema from a repository - Select GitHub account, repository, branch, and Prisma schema path - -#### Result - -A Prisma schema is now linked to your project. - -The platform updates the Prisma schema in your project every time you push a schema change to your repository. - -#### Upload a schema file - -Steps: - -1. On the **Or upload your schema** section, either: - - Click on the _drop zone_ to open your file manager and select your schema - - Drag and drop your schema file to the _drop zone_ -2. Review the preview of your schema file - - - - **Note**

- - The schema preview does not contain any syntax highlighting for your schema file. - -
- -3. Click **Upload file**.
- - Prisma Data Platform - Create project - Upload your schema - Select Prisma schema file from file system - -#### Result - -A Prisma schema is now linked to your project. However, the schema will not be synchronized with your project. You can manually synchronize the Prisma schema in your project by refreshing the schema in the **Schema** tab of your project. - -To keep your schema in sync with your project, you can link the project to a GitHub repository. - -#### What's next - -You can now use [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console) with the latest version of your Prisma schema. - -## (Optional) Enable schema synchronization - -After you create the project, you can enable automated schema synchronization on the **Get started** screen. This means that if you push your Prisma schema to a GitHub repository, you can link the Prisma schema and the GitHub repository to your project. - -With this, the platform can keep the Prisma schema up-to-date for your project and also keep the data models in **Data Browser** and **Query Console** updated with the latest version of your Prisma schema. - -### Steps - -1. On the **Get started** screen, from **GitHub Accounts & Organizations**, select a GitHub account or an organization. -2. From **Repository**, select the GitHub repository you want to import. -3. From **Branch**, select the branch you want to import. -4. In **Prisma schema path**, enter the path to the `schema.prisma` file. - - - - **Note**

- - The pre-filled path `prisma/schema.prisma` is the default path. Change it to the path you use for your project. - -
- -5. Click **Link Prisma schema**.
- Prisma Data Platform - Create project - Enable Prisma schema synchronization - Select GitHub account, repository, branch, and Prisma schema path - -### Result - -The repository and the Prisma schema are now linked to your project. The platform updates the Prisma schema in your project every time you push a change to it. - -### What's next - -You can now use [Data Browser](/platform/classic-projects/platform/data-browser) and [Query Console](/platform/classic-projects/platform/query-console) with the latest version of your Prisma schema. - -## (Optional) Create a Data Proxy connection string - -After you create the project, you can create and copy a Data Proxy connection string for the project on the **Get started** screen. You can then use the connection string in Prisma Client to enable connection pooling and load balancing of database connections locally or in your deployment environment. - -### Steps - -1. Click **Generate a Data Proxy connection string**. -2. Click **Create a new connection string**. -3. Enter a name for the connection string and click **Create**. -4. Copy the `prisma://` connection string. - - Prisma Data Platform - Create project - Copy Data Proxy connection string - -### What's next - -You can now [enable connection pooling with Data Proxy](/platform/classic-projects/data-proxy/use-data-proxy#enable-the-data-proxy-for-a-project) locally or in your deployment environment. - -## Next steps - -With your project created in the Prisma Data Platform, you can explore your project with **Data Browser**, **Query Console**, and **Schema Viewer**. - -- [Manage data with Data Browser](/platform/classic-projects/platform/data-browser) -- [Test and run queries with Query Console](/platform/classic-projects/platform/query-console) -- Manage schema updates with Schema Viewer - -Next, you can [develop your Prisma schema and your database models](/orm/prisma-schema/data-model/models) further and [migrate any schema changes to your database](/orm/prisma-migrate) with [`prisma migrate dev`](/orm/reference/prisma-cli-reference#migrate-dev). - -You can also change your project settings or add new environments if you want to isolate development activities with test databases and test branches, and select a different Data Proxy region for an environment. - -- Edit project settings -- Environments diff --git a/content/500-platform/600-classic-projects/100-platform/200-projects/200-edit-settings.mdx b/content/500-platform/600-classic-projects/100-platform/200-projects/200-edit-settings.mdx deleted file mode 100644 index f006a54a50..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/200-projects/200-edit-settings.mdx +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: 'Edit project settings' -metaTitle: 'Edit project settings in the Prisma Data Platform' -metaDescription: 'In the Prisma Data Platform, you can change the project display name and the project handle (URL) in the project settings.' ---- - - - -In the project settings, you can change the project display name and the project handle. - - - -## Prerequisites and considerations - -You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role. - -## Steps - -1. In the upper left, click your project handle and select **Project settings**. - Prisma Data Platform - Edit project settings - Change the project name and the project URL handle -2. In **Project Name**, change the project name. - - - - **Note**

- - The project name appears in the following places in the Prisma Data Platform:

-  • [_Projects_](https://cloud.prisma.io/projects) page
-  • [_Billing_](https://cloud.prisma.io/billing) page
-  • **Projects** drop-down in the upper left - -
- -3. In **Project Handle**, change the project handle. - - - - **Note**

- - The project handle defines the project part of the URL in the Prisma Data Platform.

- - `https://cloud.prisma.io/projects/`

- - For example, if your project handle is `nextjs-db`, your project URL is `https://cloud.prisma.io/projects/nextjs-db` - -
- -## Result - -The changes to the project name and handle are saved. diff --git a/content/500-platform/600-classic-projects/100-platform/200-projects/300-delete-project.mdx b/content/500-platform/600-classic-projects/100-platform/200-projects/300-delete-project.mdx deleted file mode 100644 index 14a0460820..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/200-projects/300-delete-project.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: 'Delete a project' -metaTitle: 'Delete a project in the Prisma Data Platform' -metaDescription: 'If you no longer need a project in the Prisma Data Platform, you can delete it from the project settings.' ---- - - - -If you no longer need a project in the Prisma Data Platform, you can delete it from the project settings. - - - -## Prerequisites and considerations - -- You must be the [owner](/platform/classic-projects/platform/members/roles-permissions) of the project. -- You can delete any project that is on the Free plan. -- To delete a project on the Scale plan, you must first downgrade it to the Free plan. - -## Steps - -1. In the upper left, click your project name and select **Project settings**. - Prisma Data Platform - Delete project - Open project settings -2. On the **Settings** tab, click **Delete Project**. -3. Click **Delete** in the confirmation box. - -## Result - -The project is deleted from the Prisma Data Platform. The database and repository associated with the project are not affected by the deletion. diff --git a/content/500-platform/600-classic-projects/100-platform/200-projects/index.mdx b/content/500-platform/600-classic-projects/100-platform/200-projects/index.mdx deleted file mode 100644 index f328d4d3e7..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/200-projects/index.mdx +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: 'Projects' -metaTitle: 'Projects in the Prisma Data Platform' -metaDescription: 'Learn how you can create and manage projects in the Prisma Data Platform' ---- - - - -A _project_ in the Prisma Data Platform is an organizational unit for your JavaScript/TypeScript application that uses Prisma ORM. - -You use projects to manage: - -- environments - - your linked GitHub repository and branch - - your database connection string - - your Data Proxy region -- members -- paid plan and billing - -In the Prisma Data Platform, to create projects, you only need to provide the connection string for your database. You can also select a Data Proxy region for the project, and if necessary, you can configure database access from the supported [static IPs](/platform/classic-projects/platform/static-ips) of the platform. - -For each project, you can edit the project name and URL handle, and when you no longer need a project, you can delete it. - -- Edit project settings -- Delete a project - -You can view all of your existing projects on the [**Projects**](https://cloud.prisma.io/projects) page. Projects are grouped in the list based on their plan in the following order: - -1. Scale -2. Free - -Within each group, project names are sorted in alphabetical order. - -Prisma Data Platform - Projects page - View all projects - - diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/100-view-all.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/100-view-all.mdx deleted file mode 100644 index f03c1de035..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/100-view-all.mdx +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: 'View all environments' -metaTitle: 'View all environments in a project in the Prisma Data Platform' -metaDescription: 'Each project in the Prisma Data Platform can have multiple environments to separate the database development activities, such as production, staging, development, and others. You can view all environments for a project from the Environments menu that appears to the right of the Projects menu.' -tocDepth: 4 ---- - - - -With a project currently open, you can view all [environments](/platform/classic-projects/platform/environments) in the project from the **Environments** drop-down (to the right of the **Projects** drop-down in the upper left). - - - -## Steps - -1. In the upper left, click the **Environments** drop-down menu. -2. Select **View all environments**. - Prisma Data Platform - Manage environments - Step 01 - Open Environments drop-down and click View all environments - -## Result - -The **Environments** tab for the project shows the list of environments with the option to search your environments by name. - -Prisma Data Platform - Manage environments - Step 01 - Open Environments drop-down and click View all environments - -## What's next - -- [Create an environment](/platform/classic-projects/platform/environments/create) -- [Change the default environment](/platform/classic-projects/platform/environments/edit-settings/change-default-environment) -- [Edit environment settings](/platform/classic-projects/platform/environments/edit-settings) -- [Delete an environment](/platform/classic-projects/platform/environments/delete) diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/200-create.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/200-create.mdx deleted file mode 100644 index 0aec3859bd..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/200-create.mdx +++ /dev/null @@ -1,267 +0,0 @@ ---- -title: 'Create an environment' -metaTitle: 'Create a new environment for a project in the Prisma Data Platform' -metaDescription: 'Create a new environment in a project in the Prisma Data Platform and associate it with a new branch, database, and Data Proxy region.' -tocDepth: 2 ---- - - - -For any project in the Prisma Data Platform, you can create multiple environments and associate each with a different database and a different Data Proxy region. - -You can use environments to isolate database development activities with separate branches and databases, and dedicate each environment to an activity, such as Development, Staging, Production, and so on. - - - -## About creating environments - -When you create a new environment on a project, the steps differ slightly depending on whether you have schema synchronization enabled on the default environment. - -The table below shows the different project configurations and provides links to the correct steps to create a new environment for each project configuration. - -| Configuration | Steps | -| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------- | -| Projects with enabled schema synchronization | [Steps](#projects-with-enabled-schema-synchronization) | -| Projects with introspected schema or no schema (empty database) or uploaded schema | [Steps](#projects-with-an-introspected-schema-or-with-no-schema) | - -## Projects with enabled schema synchronization - -If you already have schema synchronization enabled for the default Production environment, you can do the same for each new environment you create. - -### Prerequisites - -- You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role for the project. -- You have a database connection string for the new environment. -- Based on your project plan quota, check if you have the capacity for more environments. -- Create a new branch in the GitHub repository of the project and push new versions of the Prisma schema for the environment in that branch. - -### Steps - -1. From the **Environments** drop-down menu, select **Create new environment**. - Prisma Data Platform - Create environment - Open Environments drop-down menu and select Create new environment -2. In **Environment name**, enter a name for the environment. - - - - **Note**

- Use any naming convention that makes sense for your project.

- If applicable, you can use the Staging, Development, or <Feature name> conventions to dedicate an environment to a database development workflow or the development of a specific feature. - -
- -3. Enable schema synchronization for the new environment. - - - - **Important**

- - The steps to enable schema synchronization on new environments are available only if you have already enabled schema synchronization on the default Production environment for the same project. - - Additionally, you must select a branch from the same repository configured for the Production environment.

- - Because of this, you cannot select a different repository when you create a new environment. - -
- - a. From **Branch**, select the branch of the project repository that you want to use for the new environment. - - b. In **Prisma Schema path**, enter the path to your `schema.prisma` file. The pre-filled path `prisma/schema.prisma` is the default path. Change it to the path you plan to use in the environment. - -4. In **Connection string**, paste the database connection string for the new environment. -5. (Optional) From **Static IPs**, select **Enabled** if your database is behind a firewall and you can only configure external access from specific IP addresses. Copy the IP addresses and add them to the allowlist of your database. - - - - **Note**

- - For more information, see [Static egress IP address](/platform/classic-projects/platform/static-ips). - -
- - 7. Under **Data Proxy**, from the **Location** drop-down menu, select the geographic location for the Data Proxy. - - - - **Note**

- - Select a Data Proxy location that is close to the geographic location of the database for the new environment.

- If you select a location that is geographically distant from the database, then when your application sends requests to the database through the Data Proxy, you might notice some delay in the responses. - -
- - - - **Important**

- - After you create an environment, you cannot change its Data Proxy location. You can select a different Data Proxy location only when you create a new environment. - -
- -8. Click **Create environment**. - Prisma Data Platform - Create environment - Name environment, select branch, enter Prisma schema path, enter a database connection string, select Data Proxy region, enable firewalled connection via static IPs to your database - -### Result - -The platform creates a new environment for the project. The new environment appears in the **Environments** drop-down menu. - -The platform links the Prisma schema from the selected branch so that it can keep your project up-to-date with the latest schema version. Your updates to your Prisma schema keep the models and attributes up-to-date in **Data Browser**, **Query Console**, and also the schema contents in **Schema Viewer**. - -Your browser is redirected to **Data Browser** for the new environment. - -### What's next - -You can switch between the environments of a project from the **Environments** drop-down menu in the upper left (next to the **Projects** drop-down). - -Prisma Data Platform - Manage environments - Switch between environments from the Environments drop-down - -- After you switch to a different environment, **Data Browser** and **Query Console** use the database and Data Proxy location configured for that environment. -- What **Schema Viewer** shows differs depending on whether your database is empty or contains some models. For more information, see [Manage schema updates with Schema Viewer](/platform/classic-projects/platform/schema-viewer). - -## Projects with an introspected schema or with no schema - -If you do not yet have schema synchronization enabled for the Production environment of a project (that means that the database is empty or that the platform introspected and generated a Prisma schema), you can create new environments without the need to enable schema synchronization. - -### Prerequisites - -- You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role for the project to create a new environment. -- You have a database connection string for the new environment. -- Based on your project plan quota, check if you have the capacity for more environments. - -### Steps - -1. From the **Environments** drop-down menu, select **Create new environment**. - -{' '} - -Prisma Data Platform - Create environment - Open Environments drop-down menu and select Create new environment - -2. In **Environment name**, enter a name for the environment. - - - - **Note**

- Use any naming convention that makes sense for your project.

- If applicable, you can use the Staging, Development, or <Feature name> conventions to dedicate an environment to a database development workflow or the development of a specific feature. - -
- -3. In **Connection string**, paste the database connection string for the new environment. -4. (Optional) From **Static IPs**, select **Enabled** if your database is behind a firewall and you can only configure external access from specific IP addresses. Copy the IP addresses and add them to the allowlist of your database. - - - - **Note**

- - For more information, see Static egress IP address. - -
- -5. Under **Data Proxy**, from the **Location** drop-down menu, select the geographic location for the Data Proxy. - - - - **Note**

- - Select a Data Proxy location that is close to the geographic location of the database for the new environment.

- If you select a location that is geographically distant from the database, then when your application sends requests to the database through the Data Proxy, you might notice some delay in the responses. - -
- - - - **Important**

- - After you create an environment, you cannot change its Data Proxy location. You can select a different Data Proxy location only when you create a new environment. - -
- -6. Click **Create environment**. - Prisma Data Platform - Create environment - Name environment, select branch, enter Prisma schema path, enter a database connection string, select Data Proxy region, enable firewalled connection via static IPs to your database - -### Result - -The platform creates a new environment for the project. The new environment appears in the **Environments** drop-down menu. - -#### If the database for the new environment does not contain any models - -You see a notification that the database for the new environment is empty. Because the database does not contain any models, the introspection cannot generate a Prisma schema. - -As a result, **Data Browser** or **Query Console** for the environment remain inactive. You can start using them after you enable Prisma schema synchronization for the environment. - -Your browser is redirected to **Schema Viewer** for the new environment. - -#### If the database for the new environment contains models - -The platform introspects the database to read the data models so that it can generate the Prisma schema. The Prisma schema enables the features in **Data Browser** and **Query Console**, where you can edit and query your data, or view your schema. - -Your browser is redirected to **Data Browser** for the new environment. - -#### If introspection fails and can't generate a schema - -You will be prompted with an error notification that introspection failed. This means the environment was not created. The error prompt will contain an **Upload a schema** button that will allow you to complete environment creation by [uploading a schema](#upload-a-schema-file). - -##### Upload a schema file - -Steps: - -1. On the notification, click **Upload a schema file** - - Prisma Data Platform - Create environment - Upload a schema file button - -2. On the **Upload a schema file** section, either - - Click on the _drop zone_ to open your file manager and select your schema - - Drag and drop your schema file to the _drop zone_ -3. Review the preview of your schema file - - - - **Note**

- - The schema preview does not contain any syntax highlighting for your schema file. - -
- -4. Click **Upload file**.
- - Prisma Data Platform - Create environment - Upload your schema - Select Prisma schema file from file system - -### What's next - -You can switch between the environments of a project from the **Environments** drop-down menu in the upper left (next to the **Projects** drop-down). - -Prisma Data Platform - Manage environments - Switch between environments from the Environments drop-down - -- After you switch to a different environment, **Data Browser** and **Query Console** use the database and Data Proxy location configured for that environment. -- What **Schema Viewer** shows differs depending on whether your database is empty or contains some models. For more information, see Manage schema updates with Schema Viewer. diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/100-edit-name-and-url-handle.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/100-edit-name-and-url-handle.mdx deleted file mode 100644 index a055293c9e..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/100-edit-name-and-url-handle.mdx +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: 'Change environment name and URL handle' -metaTitle: 'Change the environment name and URL handle for a project in the Prisma Data Platform' -metaDescription: 'In a project in the Prisma Data Platform, you can change the environment name and URL handle and modify how the environment appears in the interface and in the URL that leads to the environment.' -tocDepth: 4 ---- - - - -In a Prisma Data Platform project, you can change the environment name. In the interface, the environment name appears in the **Environments** drop-down menu and in the **Environments** tab for a project. -You can also change the URL handle for an environment. This changes the URL that you can use to reach the environment. The URL format below shows how an environment URL handle appears after the project handle. - -`https://cloud.prisma.io///` - -- `github_username`. Your GitHub username. -- `project_name`. The URL handle of a project in the Prisma Data Platform. -- `environment_name`. The URL handle of a project environment in the Prisma Data Platform. - - - -## Prerequisites - -You must have the Project owner or Admin role for the project to change the environment name and URL handle. - -## Steps - -1. In the Prisma Data Platform, open a project. -2. In the upper left, click the **Projects** drop-down and select **Project settings**. -3. Select the **Environments** tab. -4. Click the three-dot menu for an environment and select **Settings**. -5. (Optional) In **Environment Name**, change the name for the environment. -6. (Optional) In **Environment Handle**, change the URL handle for the environment. -7. Click **Update Environment**. - -Prisma Data Platform - Edit environment settings - Change environment name and URL handle and click Update environment diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/300-change-default-environment.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/300-change-default-environment.mdx deleted file mode 100644 index 9aac7b152f..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/300-change-default-environment.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: 'Change the default environment' -metaTitle: 'Change the default project environment in the Prisma Data Platform' -metaDescription: 'Every Prisma Data Platform project has a default environment. This default environment determines which database, Data Proxy location, and GitHub repository a person uses when they open Data Browser, Query Console, or Schema Viewer in that project. You can set any environment in a project to be the default environment.' -tocDepth: 4 ---- - - - -Every Prisma Data Platform project has a default [environment](/platform/classic-projects/platform/environments). This default environment determines which database, Data Proxy location, and GitHub repository a person uses when they open Data Browser, Query Console, or Schema Viewer in that project. You can set any environment in a project to be the default environment. - - - -## Prerequisites - -You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or [Admin](/platform/classic-projects/platform/members/roles-permissions) role for the project to change the default environment. - -## Steps - -1. In the Prisma Data Platform, open a project. -2. In the upper left, click the **Projects** drop-down and select **Project settings**. -3. Select the **Environments** tab. -4. Click the three-dot menu for an environment and select **Make default**. - Prisma Data Platform - Manage environments - Step 01 - Open Environments drop-down and click View all environments - -## Result - -When someone opens the project, they use Data Browser, Query Console, and Schema Viewer in the new default environment. diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/index.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/index.mdx deleted file mode 100644 index 5d9dd7f09a..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/300-edit-settings/index.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: 'Edit environment settings' -metaTitle: 'Edit environment settings' -metaDescription: 'For each environment of a project in the Prisma Data Platform, you can change the environment name, URL handle, or set that environment as the default for the project.' -tocDepth: 4 ---- - - - -You can edit the following settings for any [environment](/platform/classic-projects/platform/environments) in a project: - -- environment name -- environment URL handle -- set an environment as the default - - - -**Important**

- -You cannot change the Data Proxy location or the database connection string after you create an environment. You can do both only when you create a new environment. - -
- -
- -## In this section - - diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/400-delete.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/400-delete.mdx deleted file mode 100644 index ddc1d3555a..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/400-delete.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: 'Delete an environment' -metaTitle: 'Delete a project environment in the Prisma Data Platform' -metaDescription: 'If you no longer need an environment in your project or want to reduce the number of environments to the quota in the Scale plan, you can delete one of the project environments.' -tocDepth: 4 ---- - - - -If you no longer need an [environment](/platform/classic-projects/platform/environments) in your project or want to reduce the number of environments to the quota in the Scale plan, you can delete one of the project environments. - - - -**Important**

- -You cannot delete the default environment. To delete the current default environment, you must first [make one of the other environments the default](/platform/classic-projects/platform/environments/edit-settings/change-default-environment). - -
- -
- -## Prerequisites - -- You must have the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or [Admin](/platform/classic-projects/platform/members/roles-permissions) role for the project to delete one of its environments. - -## Steps - -1. In the Prisma Data Platform, open a project. -2. In the upper left, click the **Projects** drop-down and select **Project settings**. -3. Select the **Environments** tab. -4. Click the three-dot menu of an environment and select **Delete**. - Prisma Data Platform - Delete an environment - Environments tab select three-dot menu and select Delete diff --git a/content/500-platform/600-classic-projects/100-platform/250-environments/index.mdx b/content/500-platform/600-classic-projects/100-platform/250-environments/index.mdx deleted file mode 100644 index cc075b9ef7..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/250-environments/index.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: 'Environments' -metaTitle: 'Environments' -metaDescription: 'In a project in the Prisma Data Platform, you can create multiple environments to associate a Prisma schema on a repository branch with a database and, thus, separate database development activities with JavaScript/TypeScript and Prisma ORM.' -tocDepth: 4 ---- - - - -For any project in the Prisma Data Platform, you can create multiple environments. You can associate each environment with a different database, Data Proxy location, and a different branch of your GitHub repository (if schema synchronization from GitHub is enabled). - - - -## About environments in the Prisma Data Platform - -You can dedicate each environment to a different stage of your database application life-cycle, such as production, staging, development, or any others that make sense for your project. - -For each new environment in a [project](/platform/classic-projects), you define: - -- A database connection string -- A Data Proxy region -- (if schema synchronization is enabled) a GitHub branch from the same repository as the Production environment - -## Default environment of a project - -When you first create a project, the platform defines the default environment of the project. The default environment has the name **Production**. - -When you or your team members open the project, you always start on the default **Production** environment. You can see the name of your current environment in the **Environments** drop-down menu in the upper left. - -Prisma Data Platform - Manage environments - Step 01 - Open Environments drop-down and click View all environments - -Until you add another environment and switch to that, the activity that you and your team members carry out in **Data Browser**, **Query Console**, and **Schema Viewer** occurs in the **Production** environment. - -- When you manipulate data in **Data Browser** or run queries in **Query Console**, you do so on the database and the Data Proxy region that are defined in the **Production** environment. -- When you view the Prisma schema in **Schema Viewer**, you do so for the Prisma schema file from the GitHub repository and branch defined in the **Production environment**. - -After you add more environments, you can switch to another environment from the **Environments** drop-down menu. - -Prisma Data Platform - Manage project members - Switch environments - -## In this section - - diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/050-roles-permissions.mdx b/content/500-platform/600-classic-projects/100-platform/400-members/050-roles-permissions.mdx deleted file mode 100644 index da8d88a817..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/400-members/050-roles-permissions.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: 'Roles and permissions' -metaTitle: 'Roles and permissions' -metaDescription: 'Prisma Data Platform supports role-based access (RBAC) to projects. You can use the Admin, Developer, Collaborator, and Viewer roles to assign to team members and control which parts of the project they can view or edit.' -toc: true ---- - - - -Prisma Data Platform supports role-based access (RBAC) to projects. - - - -## Roles - -Except for the role of Project owner, you can assign any of the roles below to team members. - -- Project owner -- Admin -- Developer -- Collaborator -- Viewer - -To add new team members, you need to use their GitHub username and they need to have an account in Prisma Data Platform. - -## Permissions - -Each role has a fixed set of permissions. When you assign a role to a team member, you grant them the set of permissions that apply to the role. The table below shows the permissions for each role. - - -| Feature | Project owner | Admin | Developer | Collaborator | Viewer | -| --------------------------------------- | :------------ | :---- | :-------- | :----------- | :----- | -| **Data Browser** | | | | | | -| View data | ✅ | ✅ | ✅ | ✅ | ✅ | -| Copy data | ✅ | ✅ | ✅ | ✅ | ✅ | -| Edit data | ✅ | ✅ | ✅ | ✅ | ⛔️ | -| **Query Console** | | | | | | -| Add and run test queries | ✅ | ✅ | ✅ | ✅ | ✅ | -| **Schema Viewer** | | | | | | -| View schema | ✅ | ✅ | ✅ | ⛔️ | ⛔️ | -| Refresh schema (with introspection) | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Link a GitHub repository to a project | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Link a branch to a project environment | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| **Team members** | | | | | | -| Invite new team members | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Edit the roles of team members | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Delete team members | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| **Environments** | | | | | | -| View all environments | ✅ | ✅ | ✅ | ✅ | ✅ | -| Switch environments | ✅ | ✅ | ✅ | ✅ | ✅ | -| Create a new environment | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Link a GitHub repository to the project | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Link a branch to a project environment | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| View and edit environment settings | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Delete environment | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| **Project** | | | | | | -| View project settings | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Edit project settings | ✅ | ✅ | ⛔️ | ⛔️ | ⛔️ | -| Delete project | ✅ | ⛔️ | ⛔️ | ⛔️ | ⛔️ | diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/100-add.mdx b/content/500-platform/600-classic-projects/100-platform/400-members/100-add.mdx deleted file mode 100644 index 980ef829e0..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/400-members/100-add.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: 'Add a team member' -metaTitle: 'Add a team member' -metaDescription: 'In Prisma Data Platform, you invite team members to a project. To invite a team member, you provide their GitHub username and assign them a role.' ---- - - - -In Prisma Data Platform, you invite team members to a project. To invite a team member, you provide their GitHub username and assign them a role. - - - -## Prerequisites - -- You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role. -- You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role. -- The new team member must have logged in to the platform with a GitHub account. -- You know the GitHub username of the new team member. -- Your project plan has available quota to add new team members. - -## Steps - -1. From the [Projects](https://cloud.prisma.io/projects) page, select the project to which you want to add a team member. -2. From the **Projects** drop-down in the upper-left, select **Project settings**. -3. Click **Team members**. -4. Enter the GitHub username in the box and click **Invite team member**. -5. From the **Role** drop-down menu, select a [role](/platform/classic-projects/platform/members/roles-permissions) for the new team member. - - - - **Note**

- - On the Free plan, you can only assign the [Admin](/platform/classic-projects/platform/members/roles-permissions) role.

- On the Scale plan, you can assign any of the [available roles](/platform/classic-projects/platform/members/roles-permissions). - -
- -Team members - invite and select a role - -6. Click **Save**. - -## Result - -The new team member can now see the project from the [Projects](https://cloud.prisma.io/projects) page. The team member can see and perform actions based on the granted [role](/platform/classic-projects/platform/members/roles-permissions). diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/300-change-role.mdx b/content/500-platform/600-classic-projects/100-platform/400-members/300-change-role.mdx deleted file mode 100644 index dd47f51e33..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/400-members/300-change-role.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: 'Change the role of a team member' -metaTitle: 'Change the role of a team member' -metaDescription: 'You can change the role of any of the team members on a project.' ---- - - - -You can change the role of any of your team members if you need to grant them more permissions or reduce the scope of their role on the project. - - - -## Prerequisites - -You are the Project owner or have the Admin role. - -## Steps - -1. Go to the [**Projects**](https://cloud.prisma.io/projects) page. -2. Select the project to which you want to add a collaborator. -3. From the **Projects** drop-down in the upper left, select **Project settings**. -4. Click **Team members**. -5. Click **Edit** for the team member that receives a new role. -6. From **Role**, select the new role of the team member. -7. Click **Save**. - -## Result - -When your team member refreshes their browser, they have access only to the features available for their new role. diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/400-remove.mdx b/content/500-platform/600-classic-projects/100-platform/400-members/400-remove.mdx deleted file mode 100644 index 4cf003c978..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/400-members/400-remove.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: 'Remove a team member' -metaTitle: 'Remove a team member' -metaDescription: 'You can remove a team member from a project when, for example, they leave the team.' ---- - - - -You can remove a team member from a project when, for example, they leave the team. - - - -## Prerequisites - -You are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role. - -## Steps - -1. Go to the [Projects](https://cloud.prisma.io/projects) page. -2. Select the project to which you want to add a collaborator. -3. From the **Projects** drop-down in the upper left, select **Project settings**. -4. Click **Team members**. -5. Click **Edit** for the team member you want to remove. -6. In the pop-up window, click **Remove from project**. diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.png b/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.png deleted file mode 100644 index 782a92247f..0000000000 Binary files a/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.snagx b/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.snagx deleted file mode 100644 index e00acbcbfb..0000000000 Binary files a/content/500-platform/600-classic-projects/100-platform/400-members/images/team-members-invite-and-select-role.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/100-platform/400-members/index.mdx b/content/500-platform/600-classic-projects/100-platform/400-members/index.mdx deleted file mode 100644 index 4670482fa7..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/400-members/index.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: 'Team members' -metaTitle: 'Team members' -metaDescription: 'Add team members to your project in the Prisma Data Platform to make use of the collaborative environment in the platform. You can assign a role to each team member to help you administrate, develop, or change the data of your application that uses Prisma.' ---- - - - -Add team members to your project in the Prisma Data Platform. Team members with appropriate roles can edit the data, administrate, and develop your Prisma applications. - - - diff --git a/content/500-platform/600-classic-projects/100-platform/500-data-browser.mdx b/content/500-platform/600-classic-projects/100-platform/500-data-browser.mdx deleted file mode 100644 index a5c83c05dc..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/500-data-browser.mdx +++ /dev/null @@ -1,275 +0,0 @@ ---- -title: 'Manage data with Data Browser' -metaTitle: 'Manage data with Data Browser' -metaDescription: 'Manage the data of your Prisma Data Platform project in Data Browser.' -toc: true -tocDepth: 4 ---- - - - -Use **Data Browser** in the Prisma Data Platform to view and edit your application data. - - - -## Models (tables or collections) - -When you first open **Data Browser**, you see a list of all models defined in your Prisma schema file. - - - -**What is a model?**

- -The term **model** refers to the data model definitions that you add to the Prisma schema file. Depending on the database that you use, a model definition, such as `model User`, refers to a **table** in a relational database (PostgreSQL, MySQL, SQL Server, SQLite, CockroachDB) or a **collection** in MongoDB.

-For more information, see [Defining models](/orm/prisma-schema/data-model/models#defining-models). - -
- -You can select a model and its data opens in a new tab. - -Data Browser - Models view - -### Open and close models - -To open another model, click the **+** button. - -To close a model, click the the **x** button in the model tab. - -Data Browser - Open and close models - -### Icons of data types in models - -The data type for each field is indicated with an icon in the header. - -The table below lists all data types and their identifying icon. - -| Field data type | Description | -| :-------------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------- | -| String type | Text | -| Number type | Integer | -| Datetime type | Date-time

| -| Boolean type | Boolean
| -| Enum type | Pre-defined list of values (`enum` data type) | -| Array type | List of related records from another model | -| Object type | The `{}` symbol can refer to one of the two types of fields.

• Relation field
• JSON field | - -### Keyboard shortcuts in models - -When you open a model, a number of keyboard shortcuts are available to browse and manipulate the data in the model. - - - -**Note**

-With **Data Browser** open, you can open the keyboard shortcuts modal by pressing Cmd ⌘+/ on macOS or Ctrl+/ on Windows. - -
- -Data Browser - Keyboard shortcuts - -## Edit data - -In the model view, you can edit data directly in the model cells. You can copy and paste values in cells. You can add new records as well as delete existing records. - -You must confirm every edit operation (add, edit, or delete). You confirm added and edited records with the **Save change** button. When you select records and click **Delete records**, you confirm the deletion in a dialog box. - -You can accumulate multiple added records and edited cells, which you can then finalize with the **Save changes** button. - -You can select multiple records and delete them at once with the **Delete records** button. When you delete multiple records, the operation completes immediately (after you confirm it). - -In addition, if you have any accumulated added or edited records and then decide to delete records, the deletion also force-saves the accumulated edits. - -You can discard any accumulated changes with the **Discard changes** button. - -### Copy and paste - -You can copy the value of any table cell using: - -- Cmd ⌘ + C   on macOS -- Ctrl + C     on Windows - -To paste in another cell, first double-click the cell to enter edit mode, and then use: - -- Cmd ⌘ + V   on macOS -- Ctrl + V     on Windows - -### Add a record - -1. In the model view, click **Add record**. -2. Based on the data allowed in each field, type the data for the record. - - | Field data type | Description | - | :-------------------------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | String type | Text | - | Number type | Integer

If such a field has `autoincrement()` pre-filled, do not edit the cell and do not add a number manually. | - | Datetime type | Date-time

Date-time fields contain a long string of numbers, letters, and others. As a best practice, copy the value of another date-time cell and modify it as necessary before pasting in the field. | - | Boolean type | Boolean

Select `true` or `false`. | - | Enum type | Pre-defined list

Double-click a cell in the field and select one of the pre-defined options. | - | Array type | List of related records from another model

It typically refers to a list of records that exist in another model in the database. If you are adding a new record and records from the related model do not yet exist, you do not need to enter anything in the current model. | - | Object type | The `{}` symbol can refer to one of the two types of fields.

• Relation field
• JSON field

**Relation with a model defined separately in the database**

Typically, you need to select the same value as any of the previous records
Click the name of the model to see the list of values which you can then select for the related field.

**JSON field**

Double-click the field to edit the JSON data. As a best practice, validate the edited JSON data in a validator and paste it back in the cell. | - -3. (Optional) If you are unhappy with your changes, click **Discard changes** and start over. -4. Click **Save 1 change**. - -### Edit a record - -1. Double-click a cell with existing data to edit. -2. (Optional) If you are unhappy with your changes, click **Discard changes** and start over. -3. Click **Save 1 change**. - -### Delete a record - -1. From the left column, select the check box for the record you want to delete. -2. Click **Delete 1 record**. -3. Click **Delete** in the confirmation dialog. - -### Edit multiple records at once - -You can add multiple records, edit multiple cells and, thus, accumulate multiple edits. - -In the end, click **Save changes** to finalize them. - - - -**Warning**

-Deleting a record is a separate operation that cannot be accumulated. If you delete a record while having unsaved edits, the delete operation first force-saves the unsaved edits and then completes. - -
- -Data Browser - Save multiple data edits - -## Filters - -### Filter data - -Use the **Filters** menu to filter data in the model by adding conditions. - -In the **Filters** menu, the first condition that you add is the `where` clause. - -When you add multiple conditions, **Data Browser** filters the results so that all conditions apply in combination. Each new condition indicates this with the `and` operator, which appears in front. - -**Steps** - -1. Click **Filters** to open the **Filters** menu. - - - - **Note**

- Click **Filters** again if you want to hide the menu. - -
- -2. Click **Add a new filter**. -3. Configure the condition. - 1. Select the field by which you want to filter. - 2. Select a comparison operator. - - **equals** - - **in** - - **notin** - - **lt** - - **lte** - - **gt** - - **gte** - - **not** - 3. Type the value you want to use for the condition.
- **Step result**: **Data Browser** updates the data in the model immediately, based on the condition. -4. To add a new filter, click **Add a new filter** and repeat the steps above. -5. To remove a filter, click the **x** button on the right. - Data Browser - add and remove filters -6. To remove all filters, click **Clear all**. - -**Result** - -- The data in the model is filtered based on the combination of all conditions you add. -- In the **Filters** menu, the default value of **None** changes to display the number of filters you add. - -### Show and hide fields - -You can select which fields to view or hide by using the **Fields** menu. - - - -**What is a field?**

- -A **field** is a property of a model which you add in the data model definitions in the Prisma schema file. Depending on the database that you use, a field, such as the `title` field in `model User { title String }`, refers to a **column** in a relational database (PostgreSQL, MySQL, SQL Server, SQLite, CockroachDB) or a **document field** in MongoDB.

-For more information, see [Defining fields](/orm/prisma-schema/data-model/models#defining-fields). - -
- -**Steps** - -1. Click the **Fields** menu. -2. Select only the fields you want to see and deselect any fields you want to hide. - Data Browser - show and hide fields - -**Result** - -The model is immediately filtered to hide the data from any fields you have deselected. - -Also, the **Fields** menu shows the number of fields that are currently selected. - -### Show and hide records - -You can also select to show or skip a specific number of records in the model view. - - - -**What is a record?**

- -A **record** refers to a **row of data in a table** in a relational database (PostgreSQL, MySQL, SQL Server, SQLite, CockroachDB) or a **document** in MongoDB. - -
- -**Steps** - -1. Click the **Showing** menu. -2. In the **Take** box, specify the maximum number of records that you want the model view to show. -3. In the **Skip** box, specify how many of the first records you want to hide. - Data Browser - Show and hide records - -**Result** - -The model is immediately filtered to show or hide records based on your selection. - -The **Showing** menu indicates how many records are shown out of how many available records are in the model. - -## Sort data - -Click a field title to sort by the field data. - -The first click sorts the data in ascending order, the second - in descending order. - -Data Browser - Sort data - -## Limitations - -The response size when loading data on the Data Browser is limited to 4MB. If the size of the data requested exceeds 4MB, you will run into Prisma Client Error on the Data Browser. diff --git a/content/500-platform/600-classic-projects/100-platform/600-query-console.mdx b/content/500-platform/600-classic-projects/100-platform/600-query-console.mdx deleted file mode 100644 index 025ab9cca0..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/600-query-console.mdx +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: 'Test and run queries with Query Console' -metaTitle: 'Test and run queries with Query Console' -metaDescription: 'Query Console' -toc: true -tocDepth: 4 ---- - - - -Use Query Console to run the 3 pre-defined `findMany()` test queries or add and test queries of your own using the [Prisma Client API for model queries](/orm/reference/prisma-client-reference#model-queries). - - - -## UI components - -Query Console is comprised of 2 major UI components - **Query Editor** and **Query Results Console**. - -Query Console - UI Components - -| UI component | Description | -| --------------------- | ----------------------------------------------------------------------------------- | -| Query Editor | • Add, edit, delete queries using the Prisma Client API
• Run a selected query | -| Query Results Console | View the results from the selected query | - -## Default model queries - -The default queries available in Query Console use the `findMany()` method and are based on a model defined in the Prisma schema file. - - - -**Note**

-The model queries listed below are from an example application that has the `User` model. - -
- -- `findMany()` for the first 100 records in the `User` model -- `findMany()` for the first 100 records in the `User` model that match a criteria -- `findMany()` for the first 100 records in the `User` model but only return data from 2 fields - -## Run a query - -You can test and run queries for your app using Prisma Client from Query Console and view their results on the right side of the screen. - -**Steps** - -1. In the Query Editor, place the cursor anywhere in a query block. -2. Run the query using one of the 3 available methods. - - Click the **Run active query** button in the upper-left. - - Click the **Play** (**Run query**) button at the left margin of the editor. - - Press Cmd + Enter (on macOS) or Ctrl + Enter (on Windows). - Query Console - Run a query - -**Result** - -The query results appear in the right side in the Query Results Console. - -## Add a query - -When you add or edit existing queries, Query Console supports the same syntax highlighting and autocompletion features available with the Prisma extension in Visual Studio Code or other modern IDEs. - -**Steps** - -1. Add a new line at the end of an existing query. -2. Define your query. Autocomplete is available as you type the available Prisma models and query methods based on the generated Prisma Client for the app. - Query Console - Add new query and use autocomplete - -**What's next** - -After you add a query, you can use the green button to test it. - -## Limitations - -The response size when loading data on the Query Console is limited to 4MB. If the size of the data requested exceeds 4MB, you will run into Prisma Client Error on the Query Console. diff --git a/content/500-platform/600-classic-projects/100-platform/700-schema-viewer.mdx b/content/500-platform/600-classic-projects/100-platform/700-schema-viewer.mdx deleted file mode 100644 index 54a3e94d0e..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/700-schema-viewer.mdx +++ /dev/null @@ -1,132 +0,0 @@ ---- -title: 'Manage schema updates with Schema Viewer' -metaTitle: 'Manage schema updates with Schema Viewer' -metaDescription: 'View your Prisma project schema in the Prisma Data Platform in Schema Viewer' -toc: true -tocDepth: 2 ---- - - - -In the Prisma Data Platform, you can use **Schema Viewer** to: - -- view the contents of the Prisma schema file for the currently selected environment of a Prisma project -- manage how the Prisma schema is linked and updated for the currently selected environment - - - -## About Schema Viewer - -After you create a project, **Schema Viewer** can show different options and these depend on whether you enabled schema synchronization and whether the database was empty. - -- [**Projects with schema synchronization**](#projects-with-schema-synchronization). For such projects, **Schema Viewer** shows the latest version of your Prisma schema with details about the GitHub repository and branch and the time when the schema was last updated. This means that when you created your project or after that, you enabled schema synchronization from GitHub and the platform can automatically read the updates of the `schema.prisma` file and keep that up-to-date in **Schema Viewer**. -- [**Projects with an introspected schema**](#projects-with-an-introspected-schema). For such projects, **Schema Viewer** shows the Prisma schema from when the platform last introspected your database. For such projects, you can manually trigger a new introspection and you can also decide to enable schema synchronization from GitHub. -- [**Projects without a schema**](#projects-without-a-schema). Such projects had an empty database (no models or collections) when you created the project and **Schema Viewer** provides the option to enable schema synchronization or manually trigger a new introspection. - -## Projects with schema synchronization - -When you have schema synchronization enabled for your project, **Schema Viewer** shows the contents of the most recent version of your Prisma schema file as synced from the GitHub repository and branch for the currently selected project environment. - -You can view information about: - -- GitHub repository and branch -- last time the Prisma schema was synchronized in the platform -- Prisma schema file path - -Schema Viewer - overview of Prisma schema - -When you push a new version of Prisma schema to the relevant GitHub repository and branch, the platform detects the change and updates the schema. This keeps the contents in **Schema Viewer** up-to-date and updates the models in [**Data Browser**](/platform/classic-projects/platform/data-browser) and [**Query Console**](/platform/classic-projects/platform/query-console) so that you and your team always work with the latest models and attributes in your database. - -## Projects with an introspected schema - -If you create a project with a database that contains some models and data and do not enable schema synchronization, the platform introspects the database and generates a Prisma schema for the project. - -For such projects, **Schema Viewer** shows the generated Prisma schema at the bottom and provides the option to enable schema synchronization at the top. - -If you do not plan to enable schema synchronization from a GitHub repository for the project, you can work with the generated Prisma schema at the bottom. If you have made changes to your database after the platform first introspected it, you can start a new introspection when you click **Refresh Schema**. With this action, the platform introspects your database again and generates and updates the Prisma schema in **Schema Viewer**. - - - -**Important**

- -You can use the **Refresh Schema** option only if you are the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or an [Admin](/platform/classic-projects/platform/members/roles-permissions) on the project. - -
- -Schema Viewer - Projects with introspected Prisma schema - -### Upload a schema file - -If the schema refresh fails, an error notification pops up at the top of the page with the option to upload a schema file. - -Click the **upload a schema** link in the notification. Below the **Provide a schema** section, a new **Upload a Prisma schema file** section is enabled. You can either: - -- Click on the _drop zone_ to open your file manager and select your schema -- Drag and drop your schema file to the _drop zone_ - -Review the contents of the schema file in the _drop zone_ and once you are done, click **Upload file** - - - -**Note**

- -The schema preview does not contain any syntax highlighting for your schema file. - -
- -Schema Viewer - Projects with no models and no Prisma schema - -## Projects without a schema - -If introspection fails during project creation and you chose to skip providing a schema, your project exist without an associated schema. - -For such projects, **Schema Viewer** does not show a schema and provides the option to link a Prisma schema from a GitHub repository or to manually trigger a new introspection. - -Schema Viewer - Projects with no models and no Prisma schema - -The [**Data Browser**](/platform/classic-projects/platform/data-browser) and [**Query Console**](/platform/classic-projects/platform/query-console) remain disabled until you enable schema synchronization or manually re-trigger a new introspection. - -## Enable schema synchronization - -For projects [without a schema](#projects-without-a-schema) or [with an introspected schema](#projects-with-an-introspected-schema), you can enable automated schema synchronization with the provided options. - -### Prerequisites - -To enable schema synchronization from GitHub, you must be the [Project owner](/platform/classic-projects/platform/members/roles-permissions) or have the [Admin](/platform/classic-projects/platform/members/roles-permissions) role. - -### Steps - -1. From **GitHub Account**, select a GitHub account or organization. -2. From **Repository**, select a repository. -3. From **Branch**, select the branch that you want to use for the currently selected environment. -4. (Optional) If you have a non-default path for your Prisma schema, define that in **Prisma schema path**. -5. Click **Link Prisma schema**. - -Prisma Data Platform - Schema Viewer - Provide a Prisma schema for the current project environment - -### Result - -Your Prisma schema is now linked to your current project environment. - -[**Data Browser**](/platform/classic-projects/platform/data-browser) and [**Query Console**](/platform/classic-projects/platform/query-console) are now active and you and your team members can now use them. diff --git a/content/500-platform/600-classic-projects/100-platform/800-account.mdx b/content/500-platform/600-classic-projects/100-platform/800-account.mdx deleted file mode 100644 index 57a7178fdb..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/800-account.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: 'Account' -metaTitle: 'Account' -metaDescription: 'To use the Prisma Data Platform, you can sign up with your GitHub account. If you already have an existing GitHub login session, ' -tocDepth: 4 ---- - - - -To start using the Prisma Data Platform, you need to sign up with your GitHub account. When you do so, you authorize the Prisma GitHub app to read the list of repositories (to which you have granted access). - - - -## Sign up for the Prisma Data Platform - -When you first go to the [Prisma Data Platform](https://cloud.prisma.io), use **Sign in with GitHub** to sign up. - -If your sign up is successful, you can start by [creating your first project](/platform/classic-projects/platform/projects/create). - -Prisma Data Platform - Sign up - Step 01 - Create and configure your first JavaScript/TypeScript project - -## View your GitHub account - -When you click your **Profile** icon in the upper right, the first entry in the menu is the GitHub account that you use for the Prisma Data Platform. - -Prisma Data Platform Profile menu - linked GitHub account - -## Log out from the Prisma Data Platform - -To log out, click your **Profile** icon in the upper right and select **Log out**. diff --git a/content/500-platform/600-classic-projects/100-platform/825-github-integration.mdx b/content/500-platform/600-classic-projects/100-platform/825-github-integration.mdx deleted file mode 100644 index b8e1ddb906..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/825-github-integration.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: 'GitHub integration' -metaTitle: 'GitHub integration' -metaDescription: 'The Prisma app for GitHub provides an integration between Prisma Data Platform and GitHub. With this integration, you can use your GitHub account to sign up and create an account for Prisma Data Platform, and enable Prisma schema synchronization for a project (if you push your schema to a GitHub repository).' ---- - - - -The [Prisma app for GitHub](https://github.com/apps/prisma) provides an integration between Prisma Data Platform and GitHub. With this integration, you can use your GitHub account to sign up and create an account for Prisma Data Platform, and enable Prisma schema synchronization for a project (if you push your schema to a GitHub repository). - - - -## About the Prisma app for GitHub - -When you first link a Prisma schema from a GitHub repository to a project, you install the Prisma app for GitHub. When you install the app, you provide a set of permissions to the app to read your GitHub account data as well as permissions to read all of your GitHub repositories. Specifically, you grant the permissions listed below. - -- Read access to the administration, code, and metadata of all your GitHub repositories ([you can later select to do so only for specific repositories](#grant-prisma-app-access-only-to-selected-repositories)) -- Read access to the email address of your GitHub account - -## Install the Prisma GitHub app - -You install the Prisma GitHub app when you first link a Prisma schema from a GitHub repository to a project in Prisma Data Platform. - -### Steps - -1. In the **GitHub Account** field, click and select **+ Add an organization or account**. - - GitHub integration - Add an organization or account - -2. On the **Install Prisma** page, click **Install** to confirm the installation of the Prisma app on your GitHub account.

- - GitHub integration - Grant access the GitHub app access to your email and repositories - -### Result - -When you install, you grant the Prisma app read access to all of your existing GitHub repositories as well as new repositories that you create. You can later disable this and select specific repositories that you want to use for projects in the platform. - -## Grant Prisma app access only to selected repositories - -You can grant the Prisma app access only to repositories that you select. You can select only repositories that you intend to use for projects in Prisma Data Platform. - -### Steps - -1. In GitHub, select **Settings** from the profile menu. -2. Under **Integrations** section, select **Applications**. -3. On the **Installed GitHub Apps** tab, click **Configure** for the Prisma app. -4. Under **Repository access**, select **Only select repositories** and select only repositories you intend to use for your projects. - GitHub integration - Add an organization or account -5. Click **Save**. - -### Result - -In the platform, when you create a project or configure an environment and you need to link a Prisma schema from a GitHub repository, only the selected repositories are available. - -## Uninstall the Prisma GitHub app - -If you do not need to enable Prisma schema synchronization for any of your projects and no longer need the Prisma GitHub app, you can uninstall it. - -### Steps - -1. In GitHub, select **Settings** from the profile menu. -2. Under **Integrations**, select **Applications**. -3. On the **Installed GitHubApps** tab, click **Configure** for the Prisma app. -4. Click **Uninstall**. - -### Result - -The Prisma GitHub app is now uninstalled. diff --git a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/050-connection-to-db-timed-out.mdx b/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/050-connection-to-db-timed-out.mdx deleted file mode 100644 index 724ebf9b9f..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/050-connection-to-db-timed-out.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: 'Connection to database timed out' -metaTitle: 'Connection to database timed out' -metaDescription: 'When viewing models in Data Browser or running queries in Query Console, you might see errors that the connection to your database timed out.' ---- - - - - - -## **Problem** - -The error _Connection your database timed out_ appears when you use **Data Browser** or **Query Console**. - -## **Cause** - -When you use **Data Browser** or **Query Console**, the default timeout for requests sent to the database is `15ms`. If a response is not available within this limit, the error appears. - -Several reasons related to the Data Proxy or database configuration might cause this issue. - -### **Causes related to Data Proxy** - -- The time added to a request because it is routed through the Data Proxy pushed the timeout beyond the limit -- The database and Data Proxy are in different geographic locations - -### **Causes related to the response size, database, and network latency** - -- The time it took the database to process the query pushed it over the timeout limit -- The payload response is large and could not be processed within the timeout limit -- The depth of the query is large (it includes multiple relational fields) - -## **Solution** - -While you can do little to impact potential Data Proxy or network latency, you can start with one of the following solutions. - -- Retry the operation in **Data Browser** or the query in **Query Console** and see if it completes successfully. -- Configure your Data Proxy to be closer to or in the same location as the database. - - - - **Note**

- You can do so only by creating a new environment in which you can specify a different Data Proxy location. - -
- -If you experience this issue consistently, [contact Support](/platform/classic-projects/support). diff --git a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/080-cannot-change-db-of-env.mdx b/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/080-cannot-change-db-of-env.mdx deleted file mode 100644 index e8e4f00d6e..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/080-cannot-change-db-of-env.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: 'Cannot change the database of an environment' -metaTitle: 'Cannot change the database of an environment' -metaDescription: 'If you need to update an environment in Prisma Data Platform to use another database, you cannot do so. As a workaround, you can create a new environment and configure a new database for it.' -tocDepth: 4 ---- - -## Problem - -When you create an environment, you set a database connection string and select a Data Proxy region for it. After the platform creates the environment, you cannot change the database of the environment or the Data Proxy region. - -## Solution - -If you need to use a new database for a project, you can [create a new environment](/platform/classic-projects/platform/environments/create) and configure the new database for it as well as select a different Data Proxy region. diff --git a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/100-cannot-edit-schema-file.mdx b/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/100-cannot-edit-schema-file.mdx deleted file mode 100644 index 6d768b9086..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/100-cannot-edit-schema-file.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: 'Cannot edit the Prisma schema' -metaTitle: 'Cannot edit the Prisma schema in the Prisma Data Platform' -metaDescription: 'The Prisma Data Platform does not support the complete development workflow of making iterative changes to your Prisma schema. Based on this, you cannot edit the contents of the Prisma schema file.' -toc: true -tocDepth: 4 ---- - - - -The Prisma Data Platform does not support the complete development workflow of making iterative changes to your Prisma schema, creating migrations with
`npx prisma migrate`, or pushing the schema changes directly to the database with
`npx prisma db push`. - -
- -## **Problem** - -For the purposes of consulting your Prisma schema, you can use the **Schema Viewer** to check your models and their fields and definitions, but you cannot edit and develop your Prisma schema in the Prisma Data Platform. - -## **Solution** - -Use the standard workflow of developing, migrating, and pushing of your Prisma schema locally from your code editor and committing the changes to your project repository on GitHub. diff --git a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/200-schema-file-does-not-update.mdx b/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/200-schema-file-does-not-update.mdx deleted file mode 100644 index 8dfb0804a3..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/200-schema-file-does-not-update.mdx +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: 'Schema file does not update' -metaTitle: 'Schema file does not update in the Prisma Data Platform' -metaDescription: 'The contents of the Prisma schema file does not seem to update after you make a change to the file and push that to GitHub.' ---- - - - -## **Problem** - -The contents of the Prisma schema file does not seem to update in **Schema Viewer** of your project after you make a change to the file and push that to GitHub. - -## **Solution** - -Make sure that you open **Schema Viewer** both for the correct project and environment. - -If you have multiple environments on a single project, you might be looking at an environment that is based on another branch or repository in GitHub. diff --git a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/index.mdx b/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/index.mdx deleted file mode 100644 index 12a920f441..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/900-troubleshooting/index.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: 'Troubleshooting' -metaTitle: 'Troubleshooting | Prisma Data Platform' -metaDescription: 'Learn about some issues you may run into with the Prisma Data Platform, what they mean, and how to solve them.' -toc: true -tocDepth: 4 ---- - - - - - diff --git a/content/500-platform/600-classic-projects/100-platform/index.mdx b/content/500-platform/600-classic-projects/100-platform/index.mdx deleted file mode 100644 index fa14a434d4..0000000000 --- a/content/500-platform/600-classic-projects/100-platform/index.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: 'Platform' -metaTitle: 'Platform' -metaDescription: '' -tocDepth: 4 ---- - - - - - - diff --git a/content/500-platform/600-classic-projects/980-support.mdx b/content/500-platform/600-classic-projects/980-support.mdx deleted file mode 100644 index 34d417c91e..0000000000 --- a/content/500-platform/600-classic-projects/980-support.mdx +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: 'Support' -metaTitle: 'Legacy Platform: Contact support' -metaDescription: 'Contact Support for any issues or questions you want to submit as you use the Prisma Data Platform.' ---- - - - -Contact Support for any issues or questions you want to submit as you use the Prisma Data Platform. - - - -## Steps - -1. Go to the [Prisma Data Platform](https://cloud.prisma.io) and click **Support** in the upper right. -2. Fill out all fields in the pop-up below. - - - - **Note**

- • The pop-up prefills the name and email address associated with your GitHub account.
- • All fields are mandatory except for **Attachments**. - -
- - Contact Support - fill out ticket details - -3. Click **Send**. - -## Result - -You will receive an email acknowledging the submitted ticket. - -## What's next - -As the Support team triages and responds to your ticket, you will receive replies via email. - -Keep in touch by sending replies in the same email thread until your ticket is resolved. diff --git a/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.png b/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.png deleted file mode 100644 index 3914b34a9e..0000000000 Binary files a/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.snagx b/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.snagx deleted file mode 100644 index 69ff6a63b9..0000000000 Binary files a/content/500-platform/600-classic-projects/images/account/profile-menu-github-account.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.png b/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.png deleted file mode 100644 index 6a7bd04745..0000000000 Binary files a/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.snagx b/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.snagx deleted file mode 100644 index 4722236fa2..0000000000 Binary files a/content/500-platform/600-classic-projects/images/account/sign-up-01-create-first-project.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/common/open-project-settings.png b/content/500-platform/600-classic-projects/images/common/open-project-settings.png deleted file mode 100644 index 9e6646cf93..0000000000 Binary files a/content/500-platform/600-classic-projects/images/common/open-project-settings.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/common/open-project-settings.snagx b/content/500-platform/600-classic-projects/images/common/open-project-settings.snagx deleted file mode 100644 index d2a4a3f42a..0000000000 Binary files a/content/500-platform/600-classic-projects/images/common/open-project-settings.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/common/support-pop-up.png b/content/500-platform/600-classic-projects/images/common/support-pop-up.png deleted file mode 100644 index b5f90d55ea..0000000000 Binary files a/content/500-platform/600-classic-projects/images/common/support-pop-up.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/common/support-pop-up.snagx b/content/500-platform/600-classic-projects/images/common/support-pop-up.snagx deleted file mode 100644 index a267618a08..0000000000 Binary files a/content/500-platform/600-classic-projects/images/common/support-pop-up.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/01-models-view.png b/content/500-platform/600-classic-projects/images/data-browser/01-models-view.png deleted file mode 100644 index 90f4d725bf..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/01-models-view.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/01-models-view.snagx b/content/500-platform/600-classic-projects/images/data-browser/01-models-view.snagx deleted file mode 100644 index 4e0c48f0fb..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/01-models-view.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.png b/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.png deleted file mode 100644 index 844797653e..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.snagx b/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.snagx deleted file mode 100644 index f494600c25..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/02-open-close-models.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.png b/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.png deleted file mode 100644 index 7780c5fd13..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.snagx b/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.snagx deleted file mode 100644 index 282275d251..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/03-model-view-keyboard-shortcuts.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.png b/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.png deleted file mode 100644 index 3d8346b47a..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.snagx b/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.snagx deleted file mode 100644 index ae9462fb9d..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/04-save-multiple-changes.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.png b/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.png deleted file mode 100644 index 21b858e5a8..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.snagx b/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.snagx deleted file mode 100644 index e72eefba5b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/05-add-remove-filters.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.png b/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.png deleted file mode 100644 index 47fa0cc204..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.snagx b/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.snagx deleted file mode 100644 index 577038343b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/06-show-hide-fields.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.png b/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.png deleted file mode 100644 index 4a7acf3d86..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.snagx b/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.snagx deleted file mode 100644 index 2549b18cdf..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/07-show-hide-records.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.png b/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.png deleted file mode 100644 index f6badbd6e2..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.snagx b/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.snagx deleted file mode 100644 index 1c881903e0..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-browser/08-model-sort.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-browser/array.svg b/content/500-platform/600-classic-projects/images/data-browser/array.svg deleted file mode 100644 index 79e97b3ea7..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/array.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/content/500-platform/600-classic-projects/images/data-browser/boolean.svg b/content/500-platform/600-classic-projects/images/data-browser/boolean.svg deleted file mode 100644 index 786dee492e..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/boolean.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/content/500-platform/600-classic-projects/images/data-browser/database.svg b/content/500-platform/600-classic-projects/images/data-browser/database.svg deleted file mode 100644 index 01719ab8b8..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/database.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/content/500-platform/600-classic-projects/images/data-browser/datetime.svg b/content/500-platform/600-classic-projects/images/data-browser/datetime.svg deleted file mode 100644 index 02ff3e3001..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/datetime.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/content/500-platform/600-classic-projects/images/data-browser/enum.svg b/content/500-platform/600-classic-projects/images/data-browser/enum.svg deleted file mode 100644 index a77c3a6baf..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/enum.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/content/500-platform/600-classic-projects/images/data-browser/number.svg b/content/500-platform/600-classic-projects/images/data-browser/number.svg deleted file mode 100644 index 63b2359278..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/number.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/content/500-platform/600-classic-projects/images/data-browser/object.svg b/content/500-platform/600-classic-projects/images/data-browser/object.svg deleted file mode 100644 index c356985d94..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/object.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/content/500-platform/600-classic-projects/images/data-browser/string.svg b/content/500-platform/600-classic-projects/images/data-browser/string.svg deleted file mode 100644 index 69e8115317..0000000000 --- a/content/500-platform/600-classic-projects/images/data-browser/string.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.png b/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.png deleted file mode 100644 index 9779a9cd7d..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.snagx b/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.snagx deleted file mode 100644 index 9126b69dcd..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-proxy/copy-connection-string.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.png b/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.png deleted file mode 100644 index 4f1b12eb25..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.snagx b/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.snagx deleted file mode 100644 index d3f329998c..0000000000 Binary files a/content/500-platform/600-classic-projects/images/data-proxy/create-and-name-new-connection-string.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-with-data-proxy.svg b/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-with-data-proxy.svg deleted file mode 100644 index dd7a94dc11..0000000000 --- a/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-with-data-proxy.svg +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-without-data-proxy.svg b/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-without-data-proxy.svg deleted file mode 100644 index 0dfc3ff82a..0000000000 --- a/content/500-platform/600-classic-projects/images/data-proxy/prisma-bundle-without-data-proxy.svg +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.png b/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.png deleted file mode 100644 index 92d2b302d5..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.snagx b/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.snagx deleted file mode 100644 index 2613292e4b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-01-drop-down-select-create.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-env-upload-schema-file.png b/content/500-platform/600-classic-projects/images/environments/create-env-upload-schema-file.png deleted file mode 100644 index a1ad1d91e6..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-env-upload-schema-file.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.png b/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.png deleted file mode 100644 index f848798069..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.snagx b/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.snagx deleted file mode 100644 index 3242138fe8..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-no-schema-sync-02-repo-branch-database-connection-string-data-proxy.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.png b/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.png deleted file mode 100644 index 7c4f3bd998..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.snagx b/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.snagx deleted file mode 100644 index 75b74b861a..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/create-on-schema-sync-02-connection-string-static-ips-data-proxy-region.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/default-environment.png b/content/500-platform/600-classic-projects/images/environments/default-environment.png deleted file mode 100644 index d504a7534b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/default-environment.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/default-environment.snagx b/content/500-platform/600-classic-projects/images/environments/default-environment.snagx deleted file mode 100644 index 65beed8b3f..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/default-environment.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.png b/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.png deleted file mode 100644 index 133c6573e1..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.snagx b/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.snagx deleted file mode 100644 index 63a05a06dc..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/delete-01-click-three-dot-select-delete.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.png b/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.png deleted file mode 100644 index 7d152aaf3c..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.snagx b/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.snagx deleted file mode 100644 index ad0d754402..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-database-connection-string.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.png b/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.png deleted file mode 100644 index 9500fbee67..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.snagx b/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.snagx deleted file mode 100644 index 1d81531b4c..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-default.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.png b/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.png deleted file mode 100644 index 86d85712ad..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.snagx b/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.snagx deleted file mode 100644 index 4be5c298ef..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/edit-01-change-name-and-URL-handle.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/list-all-environments.png b/content/500-platform/600-classic-projects/images/environments/list-all-environments.png deleted file mode 100644 index c6a38246ab..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/list-all-environments.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/list-all-environments.snagx b/content/500-platform/600-classic-projects/images/environments/list-all-environments.snagx deleted file mode 100644 index 768db2981c..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/list-all-environments.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/switch-environment.png b/content/500-platform/600-classic-projects/images/environments/switch-environment.png deleted file mode 100644 index a947628943..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/switch-environment.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/switch-environment.snagx b/content/500-platform/600-classic-projects/images/environments/switch-environment.snagx deleted file mode 100644 index 3df3f03430..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/switch-environment.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.png b/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.png deleted file mode 100644 index 74cf3949e1..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.snagx b/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.snagx deleted file mode 100644 index f26317f377..0000000000 Binary files a/content/500-platform/600-classic-projects/images/environments/view-all-01-environments-drop-down-view-all.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.png b/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.png deleted file mode 100644 index 9c6a94876f..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.snagx b/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.snagx deleted file mode 100644 index 1baaaff46e..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/add-github-account-or-org.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/grant-access-github-app.png b/content/500-platform/600-classic-projects/images/github/grant-access-github-app.png deleted file mode 100644 index 992ff31a70..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/grant-access-github-app.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/grant-access-github-app.snagx b/content/500-platform/600-classic-projects/images/github/grant-access-github-app.snagx deleted file mode 100644 index 00a4e8fb77..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/grant-access-github-app.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.png b/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.png deleted file mode 100644 index 5234b984a8..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.snagx b/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.snagx deleted file mode 100644 index 540c306d06..0000000000 Binary files a/content/500-platform/600-classic-projects/images/github/grant-access-to-select-github-repositories.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.png b/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.png deleted file mode 100644 index 010ebf45c7..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.snagx b/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.snagx deleted file mode 100644 index 1fd125db71..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/create-02-enable-schema-sync-github-account-branch-schema-path.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/create-02-link-schema-file-from-a-repository.png b/content/500-platform/600-classic-projects/images/projects/create-02-link-schema-file-from-a-repository.png deleted file mode 100644 index 0d1c1c483b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/create-02-link-schema-file-from-a-repository.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/create-02-upload-schema-file.png b/content/500-platform/600-classic-projects/images/projects/create-02-upload-schema-file.png deleted file mode 100644 index f6870a7c0b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/create-02-upload-schema-file.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.png b/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.png deleted file mode 100644 index 14fff63646..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.snagx b/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.snagx deleted file mode 100644 index 1bfdbaf72f..0000000000 Binary files a/content/500-platform/600-classic-projects/images/projects/prisma-data-platform-projects-page.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.png b/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.png deleted file mode 100644 index 13076e46bc..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.snagx b/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.snagx deleted file mode 100644 index 43e1c84c38..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/add-query-with-autocomplete.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/components.png b/content/500-platform/600-classic-projects/images/query-console/components.png deleted file mode 100644 index c3a3c60e28..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/components.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/components.snagx b/content/500-platform/600-classic-projects/images/query-console/components.snagx deleted file mode 100644 index 7f018ca010..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/components.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/run-query.png b/content/500-platform/600-classic-projects/images/query-console/run-query.png deleted file mode 100644 index f314ce2936..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/run-query.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/query-console/run-query.snagx b/content/500-platform/600-classic-projects/images/query-console/run-query.snagx deleted file mode 100644 index 6bc262ea3b..0000000000 Binary files a/content/500-platform/600-classic-projects/images/query-console/run-query.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/overview.png b/content/500-platform/600-classic-projects/images/schema-viewer/overview.png deleted file mode 100644 index 916a602a96..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/overview.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/overview.snagx b/content/500-platform/600-classic-projects/images/schema-viewer/overview.snagx deleted file mode 100644 index fb59b890de..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/overview.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.png b/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.png deleted file mode 100644 index 10a75b8ea5..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.snagx b/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.snagx deleted file mode 100644 index 93796b94fa..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/project-introspected-schema.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.png b/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.png deleted file mode 100644 index 49ee22b85e..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.snagx b/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.snagx deleted file mode 100644 index 48c4793e04..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/project-no-models-no-schema.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/project-schema-viewer.png b/content/500-platform/600-classic-projects/images/schema-viewer/project-schema-viewer.png deleted file mode 100644 index 207389b311..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/project-schema-viewer.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.png b/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.png deleted file mode 100644 index af23dbdc0a..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.png and /dev/null differ diff --git a/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.snagx b/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.snagx deleted file mode 100644 index 43d70ec71d..0000000000 Binary files a/content/500-platform/600-classic-projects/images/schema-viewer/provide-prisma-schema.snagx and /dev/null differ diff --git a/content/500-platform/600-classic-projects/index.mdx b/content/500-platform/600-classic-projects/index.mdx deleted file mode 100644 index da1f757a18..0000000000 --- a/content/500-platform/600-classic-projects/index.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Legacy Platform' -staticLink: true ---- diff --git a/content/600-about/200-prisma-docs/20-style-guide/05-prisma-product-names.mdx b/content/600-about/200-prisma-docs/20-style-guide/05-prisma-product-names.mdx index 27c480f5fa..2b7d89b099 100644 --- a/content/600-about/200-prisma-docs/20-style-guide/05-prisma-product-names.mdx +++ b/content/600-about/200-prisma-docs/20-style-guide/05-prisma-product-names.mdx @@ -9,14 +9,13 @@ search: false ## Use the following forms - The Prisma Data Platform (or just "PDP" - no definite article - after the first mention) +- Prisma ORM - Prisma Client (not any variation of "the Client") - Prisma schema - Prisma Migrate - Prisma CLI - Prisma Studio -- Data Proxy (_not_ Prisma Data Proxy) -- Data Browser (in the Prisma Data Platform UI, on cloud.prisma.io) -- Query Console (in the Prisma Data Platform UI, on cloud.prisma.io) -- Schema Viewer (in the Prisma Data Platform UI, on cloud.prisma.io) +- Prisma Accelerate +- Prisma Pulse Do not abbreviate any of these names, except where noted above. diff --git a/content/600-about/200-prisma-docs/20-style-guide/07-user-interace-guidelines.mdx b/content/600-about/200-prisma-docs/20-style-guide/07-user-interace-guidelines.mdx index d815d362cd..1524aae564 100644 --- a/content/600-about/200-prisma-docs/20-style-guide/07-user-interace-guidelines.mdx +++ b/content/600-about/200-prisma-docs/20-style-guide/07-user-interace-guidelines.mdx @@ -81,7 +81,7 @@ Use bold for the names of all UI controls. | window | In the **Payment information** pop-up window, enter the details for your payment method. | | screen/tab | On the **Data Browser** screen, select a record. | | pane/panel | In the **Configuration** panel, click **Network**. | -| section | Under **Data Proxy**, select **Enabled** from **Static IPs**. | +| section | Under **Accelerate**, select **Enabled** from **Static IPs**. | ## Identify UI elements at the beginning of steps @@ -179,12 +179,12 @@ In specific cases, calling out the UI control name brings clarity and makes it e ```md -- Under _Data Proxy_, from **Location**, select the geographic location for the Data Proxy. -- Under _Data Proxy_ and from **Location**, select the geographic location for the Data Proxy. +- Under _Accelerate_, from **Location**, select the geographic location for Prisma Accelerate. +- Under _Accelerate_ and from **Location**, select the geographic location for Prisma Accelerate. -Under _Data Proxy_, from the **Location** drop-down menu, select the geographic location for the Data Proxy. +Under _Accelerate_, from the **Location** drop-down menu, select the geographic location for Prisma Accelerate. ```
diff --git a/content/600-about/200-prisma-docs/30-docs-components/01-mdx-examples.mdx b/content/600-about/200-prisma-docs/30-docs-components/01-mdx-examples.mdx index 5fe47e2dd1..e789fb0277 100644 --- a/content/600-about/200-prisma-docs/30-docs-components/01-mdx-examples.mdx +++ b/content/600-about/200-prisma-docs/30-docs-components/01-mdx-examples.mdx @@ -455,7 +455,7 @@ yarn prisma init $ yarn prisma init yarn run v1.22.0 warning package.json: No license field -$ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init +$ /Users/janedoe/Desktop/tsdf/node_modules/.bin/prisma init ✔ Your Prisma schema was created at prisma/schema.prisma. You can now open it in your favorite editor. @@ -463,8 +463,8 @@ $ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init Next steps: 1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started. 2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql or sqlite. -3. Run prisma db pull to turn your database schema into a Prisma data model. -4. Run prisma generate to install Prisma Client. You can then start querying your database. +3. Run `prisma db pull` to introspect your database schema and update the Prisma schema data models accordingly. +4. Run `prisma generate` to install Prisma Client. You can then start querying your database. More information in our documentation: https://pris.ly/d/getting-started @@ -493,7 +493,7 @@ yarn prisma init $ yarn prisma init yarn run v1.22.0 warning package.json: No license field -$ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init +$ /Users/janedoe/Desktop/tsdf/node_modules/.bin/prisma init ✔ Your Prisma schema was created at prisma/schema.prisma. You can now open it in your favorite editor. @@ -501,8 +501,8 @@ $ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init Next steps: 1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started. 2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql or sqlite. -3. Run prisma db pull to turn your database schema into a Prisma data model. -4. Run prisma generate to install Prisma Client. You can then start querying your database. +3. Run `prisma db pull` to introspect your database schema and update the Prisma schema data models accordingly. +4. Run `prisma generate` to install Prisma Client. You can then start querying your database. More information in our documentation: https://pris.ly/d/getting-started @@ -531,7 +531,7 @@ yarn prisma init $ yarn prisma init yarn run v1.22.0 warning package.json: No license field -$ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init +$ /Users/janedoe/Desktop/tsdf/node_modules/.bin/prisma init ✔ Your Prisma schema was created at prisma/schema.prisma. You can now open it in your favorite editor. @@ -539,8 +539,8 @@ $ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init Next steps: 1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started. 2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql or sqlite. -3. Run prisma db pull to turn your database schema into a Prisma data model. -4. Run prisma generate to install Prisma Client. You can then start querying your database. +3. Run `prisma db pull` to introspect your database schema and update the Prisma schema data models accordingly. +4. Run `prisma generate` to install Prisma Client. You can then start querying your database. More information in our documentation: https://pris.ly/d/getting-started @@ -569,7 +569,7 @@ yarn prisma init $ yarn prisma init yarn run v1.22.0 warning package.json: No license field -$ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init +$ /Users/janedoe/Desktop/tsdf/node_modules/.bin/prisma init ✔ Your Prisma schema was created at prisma/schema.prisma. You can now open it in your favorite editor. @@ -577,8 +577,8 @@ $ /Users/nikolasburk/Desktop/tsdf/node_modules/.bin/prisma init Next steps: 1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started. 2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql or sqlite. -3. Run prisma db pull to turn your database schema into a Prisma data model. -4. Run prisma generate to install Prisma Client. You can then start querying your database. +3. Run `prisma db pull` to introspect your database schema and update the Prisma schema data models accordingly. +4. Run `prisma generate` to install Prisma Client. You can then start querying your database. More information in our documentation: https://pris.ly/d/getting-started diff --git a/gatsby-node.ts b/gatsby-node.ts index 23134b52da..ec81aeb796 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -204,6 +204,7 @@ exports.createSchemaCustomization = ({ actions }: any) => { preview: Boolean deprecated: Boolean earlyaccess: Boolean + highlight: Boolean toc: Boolean hidePage: Boolean tocDepth: Int diff --git a/package-lock.json b/package-lock.json index 2f631fdbf0..11aa58e605 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,10 @@ "@mdx-js/react": "1.6.22", "@philpl/buble": "0.19.7", "@prisma/client": "^4.8.1", + "@react-aria/overlays": "^3.20.0", + "@react-aria/tooltip": "^3.7.0", + "@react-aria/utils": "^3.23.0", + "@react-stately/tooltip": "^3.4.6", "algoliasearch": "4.14.2", "babel-plugin-styled-components": "2.0.7", "gatsby": "4.22.1", @@ -2462,6 +2466,50 @@ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" }, + "node_modules/@formatjs/ecma402-abstract": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.18.2.tgz", + "integrity": "sha512-+QoPW4csYALsQIl8GbN14igZzDbuwzcpWrku9nyMXlaqAlwRBgl5V+p0vWMGFqHOw37czNXaP/lEk4wbLgcmtA==", + "dependencies": { + "@formatjs/intl-localematcher": "0.5.4", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/fast-memoize": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-2.2.0.tgz", + "integrity": "sha512-hnk/nY8FyrL5YxwP9e4r9dqeM6cAbo8PeU9UjyXojZMNvVad2Z06FAVHyR3Ecw6fza+0GH7vdJgiKIVXTMbSBA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "2.7.6", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.7.6.tgz", + "integrity": "sha512-etVau26po9+eewJKYoiBKP6743I1br0/Ie00Pb/S/PtmYfmjTcOn2YCh2yNkSZI12h6Rg+BOgQYborXk46BvkA==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/icu-skeleton-parser": "1.8.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.8.0.tgz", + "integrity": "sha512-QWLAYvM0n8hv7Nq5BEs4LKIjevpVpbGLAJgOaYzg9wABEoX1j0JO1q2/jVkO6CVlq0dbsxZCngS5aXbysYueqA==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/intl-localematcher": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz", + "integrity": "sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@gatsbyjs/parcel-namer-relative-to-cwd": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@gatsbyjs/parcel-namer-relative-to-cwd/-/parcel-namer-relative-to-cwd-1.7.0.tgz", @@ -2969,6 +3017,71 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, + "node_modules/@internationalized/date": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.5.1.tgz", + "integrity": "sha512-LUQIfwU9e+Fmutc/DpRTGXSdgYZLBegi4wygCWDSVmUdLTaMHsQyASDiJtREwanwKuQLq0hY76fCJ9J/9I2xOQ==", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@internationalized/date/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@internationalized/message": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@internationalized/message/-/message-3.1.1.tgz", + "integrity": "sha512-ZgHxf5HAPIaR0th+w0RUD62yF6vxitjlprSxmLJ1tam7FOekqRSDELMg4Cr/DdszG5YLsp5BG3FgHgqquQZbqw==", + "dependencies": { + "@swc/helpers": "^0.5.0", + "intl-messageformat": "^10.1.0" + } + }, + "node_modules/@internationalized/message/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@internationalized/number": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@internationalized/number/-/number-3.5.0.tgz", + "integrity": "sha512-ZY1BW8HT9WKYvaubbuqXbbDdHhOUMfE2zHHFJeTppid0S+pc8HtdIxFxaYMsGjCb4UsF+MEJ4n2TfU7iHnUK8w==", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@internationalized/number/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@internationalized/string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@internationalized/string/-/string-3.2.0.tgz", + "integrity": "sha512-Xx3Sy3f2c9ctT+vh8c7euEaEHQZltp0euZ3Hy4UfT3E13r6lxpUS3kgKyumEjboJZSnaZv7JhqWz3D75v+IxQg==", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@internationalized/string/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -4946,6 +5059,318 @@ "integrity": "sha512-12dZRXW36s3hRHLeD8c4S3o1ZZcnFt1NxhBrSlYepnMxatfkj5S8aIDP/G+zzUqucB//kGZZWNX3eUcmxMsEqw==", "dev": true }, + "node_modules/@react-aria/focus": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.16.0.tgz", + "integrity": "sha512-GP6EYI07E8NKQQcXHjpIocEU0vh0oi0Vcsd+/71fKS0NnTR0TUOEeil0JuuQ9ymkmPDTu51Aaaa4FxVsuN/23A==", + "dependencies": { + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/focus/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/focus/node_modules/clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/@react-aria/i18n": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@react-aria/i18n/-/i18n-3.10.0.tgz", + "integrity": "sha512-sviD5Y1pLPG49HHRmVjR+5nONrp0HK219+nu9Y7cDfUhXu2EjyhMS9t/n9/VZ69hHChZ2PnHYLEE2visu9CuCg==", + "dependencies": { + "@internationalized/date": "^3.5.1", + "@internationalized/message": "^3.1.1", + "@internationalized/number": "^3.5.0", + "@internationalized/string": "^3.2.0", + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/i18n/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/interactions": { + "version": "3.20.1", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.20.1.tgz", + "integrity": "sha512-PLNBr87+SzRhe9PvvF9qvzYeP4ofTwfKSorwmO+hjr3qoczrSXf4LRQlb27wB6hF10C7ZE/XVbUI1lj4QQrZ/g==", + "dependencies": { + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/interactions/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/overlays": { + "version": "3.20.0", + "resolved": "https://registry.npmjs.org/@react-aria/overlays/-/overlays-3.20.0.tgz", + "integrity": "sha512-2m7MpRJL5UucbEuu08lMHsiFJoDowkJV4JAIFBZYK1NzVH0vF/A+w9HRNM7jRwx2DUxE+iIsZnl8yKV/7KY8OQ==", + "dependencies": { + "@react-aria/focus": "^3.16.0", + "@react-aria/i18n": "^3.10.0", + "@react-aria/interactions": "^3.20.1", + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-aria/visually-hidden": "^3.8.8", + "@react-stately/overlays": "^3.6.4", + "@react-types/button": "^3.9.1", + "@react-types/overlays": "^3.8.4", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/overlays/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.1.tgz", + "integrity": "sha512-NqzkLFP8ZVI4GSorS0AYljC13QW2sc8bDqJOkBvkAt3M8gbcAXJWVRGtZBCRscki9RZF+rNlnPdg0G0jYkhJcg==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/ssr/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/tooltip": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@react-aria/tooltip/-/tooltip-3.7.0.tgz", + "integrity": "sha512-+u9Sftkfe09IDyPEnbbreFKS50vh9X/WTa7n1u2y3PenI9VreLpUR6czyzda4BlvQ95e9jQz1cVxUjxTNaZmBw==", + "dependencies": { + "@react-aria/focus": "^3.16.0", + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-stately/tooltip": "^3.4.6", + "@react-types/shared": "^3.22.0", + "@react-types/tooltip": "^3.4.6", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/tooltip/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/utils": { + "version": "3.23.0", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.23.0.tgz", + "integrity": "sha512-fJA63/VU4iQNT8WUvrmll3kvToqMurD69CcgVmbQ56V7ZbvlzFi44E7BpnoaofScYLLtFWRjVdaHsohT6O/big==", + "dependencies": { + "@react-aria/ssr": "^3.9.1", + "@react-stately/utils": "^3.9.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/utils/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-aria/utils/node_modules/clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/@react-aria/visually-hidden": { + "version": "3.8.8", + "resolved": "https://registry.npmjs.org/@react-aria/visually-hidden/-/visually-hidden-3.8.8.tgz", + "integrity": "sha512-Cn2PYKD4ijGDtF0+dvsh8qa4y7KTNAlkTG6h20r8Q+6UTyRNmtE2/26QEaApRF8CBiNy9/BZC/ZC4FK2OjvCoA==", + "dependencies": { + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-aria/visually-hidden/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-stately/overlays": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/@react-stately/overlays/-/overlays-3.6.4.tgz", + "integrity": "sha512-tHEaoAGpE9dSnsskqLPVKum59yGteoSqsniTopodM+miQozbpPlSjdiQnzGLroy5Afx5OZYClE616muNHUILXA==", + "dependencies": { + "@react-stately/utils": "^3.9.0", + "@react-types/overlays": "^3.8.4", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-stately/overlays/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-stately/tooltip": { + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/@react-stately/tooltip/-/tooltip-3.4.6.tgz", + "integrity": "sha512-uL93bmsXf+OOgpKLPEKfpDH4z+MK2CuqlqVxx7rshN0vjWOSoezE5nzwgee90+RpDrLNNNWTNa7n+NkDRpI1jA==", + "dependencies": { + "@react-stately/overlays": "^3.6.4", + "@react-types/tooltip": "^3.4.6", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-stately/tooltip/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-stately/utils": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.9.0.tgz", + "integrity": "sha512-yPKFY1F88HxuZ15BG2qwAYxtpE4HnIU0Ofi4CuBE0xC6I8mwo4OQjDzi+DZjxQngM9D6AeTTD6F1V8gkozA0Gw==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-stately/utils/node_modules/@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@react-types/button": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@react-types/button/-/button-3.9.1.tgz", + "integrity": "sha512-bf9iTar3PtqnyV9rA+wyFyrskZKhwmOuOd/ifYIjPs56YNVXWH5Wfqj6Dx3xdFBgtKx8mEVQxVhoX+WkHX+rtw==", + "dependencies": { + "@react-types/shared": "^3.22.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-types/overlays": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/@react-types/overlays/-/overlays-3.8.4.tgz", + "integrity": "sha512-pfgNlQnbF6RB/R2oSxyqAP3Uzz0xE/k5q4n5gUeCDNLjY5qxFHGE8xniZZ503nZYw6VBa9XMN1efDOKQyeiO0w==", + "dependencies": { + "@react-types/shared": "^3.22.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-types/shared": { + "version": "3.22.0", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.22.0.tgz", + "integrity": "sha512-yVOekZWbtSmmiThGEIARbBpnmUIuePFlLyctjvCbgJgGhz8JnEJOipLQ/a4anaWfzAgzSceQP8j/K+VOOePleA==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-types/tooltip": { + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/@react-types/tooltip/-/tooltip-3.4.6.tgz", + "integrity": "sha512-RaZewdER7ZcsNL99RhVHs8kSLyzIBkwc0W6eFZrxST2MD9J5GzkVWRhIiqtFOd5U1aYnxdJ6woq72Ef+le6Vfw==", + "dependencies": { + "@react-types/overlays": "^3.8.4", + "@react-types/shared": "^3.22.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, "node_modules/@sideway/address": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.4.tgz", @@ -13987,6 +14412,17 @@ "node": ">= 0.4" } }, + "node_modules/intl-messageformat": { + "version": "10.5.11", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-10.5.11.tgz", + "integrity": "sha512-eYq5fkFBVxc7GIFDzpFQkDOZgNayNTQn4Oufe8jw6YY6OHVw70/4pA3FyCsQ0Gb2DnvEJEMmN2tOaXUGByM+kg==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/fast-memoize": "2.2.0", + "@formatjs/icu-messageformat-parser": "2.7.6", + "tslib": "^2.4.0" + } + }, "node_modules/invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -25458,6 +25894,50 @@ } } }, + "@formatjs/ecma402-abstract": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.18.2.tgz", + "integrity": "sha512-+QoPW4csYALsQIl8GbN14igZzDbuwzcpWrku9nyMXlaqAlwRBgl5V+p0vWMGFqHOw37czNXaP/lEk4wbLgcmtA==", + "requires": { + "@formatjs/intl-localematcher": "0.5.4", + "tslib": "^2.4.0" + } + }, + "@formatjs/fast-memoize": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-2.2.0.tgz", + "integrity": "sha512-hnk/nY8FyrL5YxwP9e4r9dqeM6cAbo8PeU9UjyXojZMNvVad2Z06FAVHyR3Ecw6fza+0GH7vdJgiKIVXTMbSBA==", + "requires": { + "tslib": "^2.4.0" + } + }, + "@formatjs/icu-messageformat-parser": { + "version": "2.7.6", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.7.6.tgz", + "integrity": "sha512-etVau26po9+eewJKYoiBKP6743I1br0/Ie00Pb/S/PtmYfmjTcOn2YCh2yNkSZI12h6Rg+BOgQYborXk46BvkA==", + "requires": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/icu-skeleton-parser": "1.8.0", + "tslib": "^2.4.0" + } + }, + "@formatjs/icu-skeleton-parser": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.8.0.tgz", + "integrity": "sha512-QWLAYvM0n8hv7Nq5BEs4LKIjevpVpbGLAJgOaYzg9wABEoX1j0JO1q2/jVkO6CVlq0dbsxZCngS5aXbysYueqA==", + "requires": { + "@formatjs/ecma402-abstract": "1.18.2", + "tslib": "^2.4.0" + } + }, + "@formatjs/intl-localematcher": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz", + "integrity": "sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==", + "requires": { + "tslib": "^2.4.0" + } + }, "@gatsbyjs/parcel-namer-relative-to-cwd": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@gatsbyjs/parcel-namer-relative-to-cwd/-/parcel-namer-relative-to-cwd-1.7.0.tgz", @@ -25900,6 +26380,79 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, + "@internationalized/date": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.5.1.tgz", + "integrity": "sha512-LUQIfwU9e+Fmutc/DpRTGXSdgYZLBegi4wygCWDSVmUdLTaMHsQyASDiJtREwanwKuQLq0hY76fCJ9J/9I2xOQ==", + "requires": { + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@internationalized/message": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@internationalized/message/-/message-3.1.1.tgz", + "integrity": "sha512-ZgHxf5HAPIaR0th+w0RUD62yF6vxitjlprSxmLJ1tam7FOekqRSDELMg4Cr/DdszG5YLsp5BG3FgHgqquQZbqw==", + "requires": { + "@swc/helpers": "^0.5.0", + "intl-messageformat": "^10.1.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@internationalized/number": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@internationalized/number/-/number-3.5.0.tgz", + "integrity": "sha512-ZY1BW8HT9WKYvaubbuqXbbDdHhOUMfE2zHHFJeTppid0S+pc8HtdIxFxaYMsGjCb4UsF+MEJ4n2TfU7iHnUK8w==", + "requires": { + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@internationalized/string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@internationalized/string/-/string-3.2.0.tgz", + "integrity": "sha512-Xx3Sy3f2c9ctT+vh8c7euEaEHQZltp0euZ3Hy4UfT3E13r6lxpUS3kgKyumEjboJZSnaZv7JhqWz3D75v+IxQg==", + "requires": { + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, "@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -27122,6 +27675,286 @@ "integrity": "sha512-12dZRXW36s3hRHLeD8c4S3o1ZZcnFt1NxhBrSlYepnMxatfkj5S8aIDP/G+zzUqucB//kGZZWNX3eUcmxMsEqw==", "dev": true }, + "@react-aria/focus": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.16.0.tgz", + "integrity": "sha512-GP6EYI07E8NKQQcXHjpIocEU0vh0oi0Vcsd+/71fKS0NnTR0TUOEeil0JuuQ9ymkmPDTu51Aaaa4FxVsuN/23A==", + "requires": { + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + }, + "clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==" + } + } + }, + "@react-aria/i18n": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/@react-aria/i18n/-/i18n-3.10.0.tgz", + "integrity": "sha512-sviD5Y1pLPG49HHRmVjR+5nONrp0HK219+nu9Y7cDfUhXu2EjyhMS9t/n9/VZ69hHChZ2PnHYLEE2visu9CuCg==", + "requires": { + "@internationalized/date": "^3.5.1", + "@internationalized/message": "^3.1.1", + "@internationalized/number": "^3.5.0", + "@internationalized/string": "^3.2.0", + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-aria/interactions": { + "version": "3.20.1", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.20.1.tgz", + "integrity": "sha512-PLNBr87+SzRhe9PvvF9qvzYeP4ofTwfKSorwmO+hjr3qoczrSXf4LRQlb27wB6hF10C7ZE/XVbUI1lj4QQrZ/g==", + "requires": { + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-aria/overlays": { + "version": "3.20.0", + "resolved": "https://registry.npmjs.org/@react-aria/overlays/-/overlays-3.20.0.tgz", + "integrity": "sha512-2m7MpRJL5UucbEuu08lMHsiFJoDowkJV4JAIFBZYK1NzVH0vF/A+w9HRNM7jRwx2DUxE+iIsZnl8yKV/7KY8OQ==", + "requires": { + "@react-aria/focus": "^3.16.0", + "@react-aria/i18n": "^3.10.0", + "@react-aria/interactions": "^3.20.1", + "@react-aria/ssr": "^3.9.1", + "@react-aria/utils": "^3.23.0", + "@react-aria/visually-hidden": "^3.8.8", + "@react-stately/overlays": "^3.6.4", + "@react-types/button": "^3.9.1", + "@react-types/overlays": "^3.8.4", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-aria/ssr": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.1.tgz", + "integrity": "sha512-NqzkLFP8ZVI4GSorS0AYljC13QW2sc8bDqJOkBvkAt3M8gbcAXJWVRGtZBCRscki9RZF+rNlnPdg0G0jYkhJcg==", + "requires": { + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-aria/tooltip": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@react-aria/tooltip/-/tooltip-3.7.0.tgz", + "integrity": "sha512-+u9Sftkfe09IDyPEnbbreFKS50vh9X/WTa7n1u2y3PenI9VreLpUR6czyzda4BlvQ95e9jQz1cVxUjxTNaZmBw==", + "requires": { + "@react-aria/focus": "^3.16.0", + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-stately/tooltip": "^3.4.6", + "@react-types/shared": "^3.22.0", + "@react-types/tooltip": "^3.4.6", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-aria/utils": { + "version": "3.23.0", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.23.0.tgz", + "integrity": "sha512-fJA63/VU4iQNT8WUvrmll3kvToqMurD69CcgVmbQ56V7ZbvlzFi44E7BpnoaofScYLLtFWRjVdaHsohT6O/big==", + "requires": { + "@react-aria/ssr": "^3.9.1", + "@react-stately/utils": "^3.9.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + }, + "clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==" + } + } + }, + "@react-aria/visually-hidden": { + "version": "3.8.8", + "resolved": "https://registry.npmjs.org/@react-aria/visually-hidden/-/visually-hidden-3.8.8.tgz", + "integrity": "sha512-Cn2PYKD4ijGDtF0+dvsh8qa4y7KTNAlkTG6h20r8Q+6UTyRNmtE2/26QEaApRF8CBiNy9/BZC/ZC4FK2OjvCoA==", + "requires": { + "@react-aria/interactions": "^3.20.1", + "@react-aria/utils": "^3.23.0", + "@react-types/shared": "^3.22.0", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-stately/overlays": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/@react-stately/overlays/-/overlays-3.6.4.tgz", + "integrity": "sha512-tHEaoAGpE9dSnsskqLPVKum59yGteoSqsniTopodM+miQozbpPlSjdiQnzGLroy5Afx5OZYClE616muNHUILXA==", + "requires": { + "@react-stately/utils": "^3.9.0", + "@react-types/overlays": "^3.8.4", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-stately/tooltip": { + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/@react-stately/tooltip/-/tooltip-3.4.6.tgz", + "integrity": "sha512-uL93bmsXf+OOgpKLPEKfpDH4z+MK2CuqlqVxx7rshN0vjWOSoezE5nzwgee90+RpDrLNNNWTNa7n+NkDRpI1jA==", + "requires": { + "@react-stately/overlays": "^3.6.4", + "@react-types/tooltip": "^3.4.6", + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-stately/utils": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.9.0.tgz", + "integrity": "sha512-yPKFY1F88HxuZ15BG2qwAYxtpE4HnIU0Ofi4CuBE0xC6I8mwo4OQjDzi+DZjxQngM9D6AeTTD6F1V8gkozA0Gw==", + "requires": { + "@swc/helpers": "^0.5.0" + }, + "dependencies": { + "@swc/helpers": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.6.tgz", + "integrity": "sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, + "@react-types/button": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@react-types/button/-/button-3.9.1.tgz", + "integrity": "sha512-bf9iTar3PtqnyV9rA+wyFyrskZKhwmOuOd/ifYIjPs56YNVXWH5Wfqj6Dx3xdFBgtKx8mEVQxVhoX+WkHX+rtw==", + "requires": { + "@react-types/shared": "^3.22.0" + } + }, + "@react-types/overlays": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/@react-types/overlays/-/overlays-3.8.4.tgz", + "integrity": "sha512-pfgNlQnbF6RB/R2oSxyqAP3Uzz0xE/k5q4n5gUeCDNLjY5qxFHGE8xniZZ503nZYw6VBa9XMN1efDOKQyeiO0w==", + "requires": { + "@react-types/shared": "^3.22.0" + } + }, + "@react-types/shared": { + "version": "3.22.0", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.22.0.tgz", + "integrity": "sha512-yVOekZWbtSmmiThGEIARbBpnmUIuePFlLyctjvCbgJgGhz8JnEJOipLQ/a4anaWfzAgzSceQP8j/K+VOOePleA==", + "requires": {} + }, + "@react-types/tooltip": { + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/@react-types/tooltip/-/tooltip-3.4.6.tgz", + "integrity": "sha512-RaZewdER7ZcsNL99RhVHs8kSLyzIBkwc0W6eFZrxST2MD9J5GzkVWRhIiqtFOd5U1aYnxdJ6woq72Ef+le6Vfw==", + "requires": { + "@react-types/overlays": "^3.8.4", + "@react-types/shared": "^3.22.0" + } + }, "@sideway/address": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.4.tgz", @@ -33986,6 +34819,17 @@ "side-channel": "^1.0.4" } }, + "intl-messageformat": { + "version": "10.5.11", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-10.5.11.tgz", + "integrity": "sha512-eYq5fkFBVxc7GIFDzpFQkDOZgNayNTQn4Oufe8jw6YY6OHVw70/4pA3FyCsQ0Gb2DnvEJEMmN2tOaXUGByM+kg==", + "requires": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/fast-memoize": "2.2.0", + "@formatjs/icu-messageformat-parser": "2.7.6", + "tslib": "^2.4.0" + } + }, "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", diff --git a/package.json b/package.json index 46c314bc0f..b88bf3633b 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,10 @@ "@mdx-js/react": "1.6.22", "@philpl/buble": "0.19.7", "@prisma/client": "^4.8.1", + "@react-aria/overlays": "^3.20.0", + "@react-aria/tooltip": "^3.7.0", + "@react-aria/utils": "^3.23.0", + "@react-stately/tooltip": "^3.4.6", "algoliasearch": "4.14.2", "babel-plugin-styled-components": "2.0.7", "gatsby": "4.22.1", diff --git a/src/components/footer.tsx b/src/components/footer.tsx index e7c1f9e5a3..a17a6946a7 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -272,16 +272,9 @@ const FooterSec = ({ - Client - - - Migrate + ORM -
- Pulse - Early Access -
+
Pulse
- Developers + Resources - Get Started + Get started - Prisma Examples + prisma-examples - Data Guide + Prisma ORM in your stack - Prisma in your Stack + Ecosystem - Support + Tutorials - Community + Playground + + + Customer stories + + + Data guide - Data Platform Status + Data Platform status - VS Code Extension + VS Code extension + - Use Cases + Contact us + Community + + - Customer Stories + Support Blog + + Data DX + Causes + + OSS Friends + Terms & Privacy + + Service Level Agreement + diff --git a/src/components/layout.tsx b/src/components/layout.tsx index 5744c61768..11d7cfc19d 100644 --- a/src/components/layout.tsx +++ b/src/components/layout.tsx @@ -181,6 +181,11 @@ export default function Layout({ return ( - {/* End of Reo Javascript */} ) diff --git a/src/icons/technologies/CockroachDBgradient.tsx b/src/icons/technologies/CockroachDBgradient.tsx new file mode 100644 index 0000000000..296bea95d6 --- /dev/null +++ b/src/icons/technologies/CockroachDBgradient.tsx @@ -0,0 +1,24 @@ +import React from 'react' + +export default () => ( + + + + + + + + + + +) diff --git a/src/icons/technologies/PlanetScale.tsx b/src/icons/technologies/PlanetScale.tsx index 455946db8f..564d87ab47 100644 --- a/src/icons/technologies/PlanetScale.tsx +++ b/src/icons/technologies/PlanetScale.tsx @@ -6,6 +6,7 @@ export default () => ( width="24px" height="24px" viewBox="0 0 24 23" + className="planetscale" version="1.1" > diff --git a/src/interfaces/Article.interface.ts b/src/interfaces/Article.interface.ts index b1a68f1468..5117f57205 100644 --- a/src/interfaces/Article.interface.ts +++ b/src/interfaces/Article.interface.ts @@ -16,11 +16,13 @@ export interface ArticleFrontmatter { duration?: string preview?: boolean earlyaccess?: boolean + highlight?: boolean toc?: boolean hidePage?: boolean tocDepth?: number codeStyle?: boolean deprecated?: boolean + hideTitle?: boolean } export interface ArticleData { diff --git a/src/pages/index.tsx b/src/pages/index.tsx index fd45349dd1..de5cd4cfe4 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -668,9 +668,9 @@ const Homepage = () => {

Databases

- Prisma works seamlessly across most popular databases and service providers.
Refer - to our Database features matrix for information about supported features and types for - each database. + Prisma ORM works seamlessly across most popular databases and service providers.
{' '} + Refer to our Database features matrix for information about supported features and types + for each database. {DatabaseData.map((e: any) => ( diff --git a/src/styles/all.css b/src/styles/all.css index 9ca551af61..eaf63bb31d 100644 --- a/src/styles/all.css +++ b/src/styles/all.css @@ -963,6 +963,11 @@ readers do not read off random characters that represent icons */ url('/fonts/fa-solid-900.woff2') format('woff2'); } +.fa-rabbit-fast:before, +.fa-rabbit-running:before { + content: '\f709'; +} + .fa-discord::before { content: '\f392'; } @@ -1040,3 +1045,6 @@ readers do not read off random characters that represent icons */ .fa-regular { font-weight: 400; } +.fa-arrow-right:before { + content: '\f061'; +} diff --git a/src/styles/layout.css b/src/styles/layout.css index ab3a86256f..0a3a40b3a0 100644 --- a/src/styles/layout.css +++ b/src/styles/layout.css @@ -90,7 +90,7 @@ html { body { /* Generic */ - --main-font-color: #1a202c; + --main-font-color: #2d3748; --main-bgd-color: #f7fafc; --header-bg-color: #ffffff; --selection-bgd-color: #0c344b; @@ -143,11 +143,11 @@ body { /* Generic */ --main-font-color: #e2e8f0; --main-bgd-color: #1a202c; + --border-color: #2d3748; --header-bg-color: #1a202c; --selection-bgd-color: #0c344b; --white-color: #ffffff; --link-color: #7f9cf5; - --border-color: #e2e8f0; --code-bgd-color: #2d3748; --code-inline-bgd-color: #2d3748; --list-bullet-color: #a0aec0; @@ -190,6 +190,11 @@ body { kbd { background: var(--main-bgd-color) !important; } + .planetscale { + path { + fill: #e2e8f0 !important; + } + } } ::selection, diff --git a/src/templates/docs.tsx b/src/templates/docs.tsx index 23d55140f8..0efabfa11b 100644 --- a/src/templates/docs.tsx +++ b/src/templates/docs.tsx @@ -18,7 +18,7 @@ const ArticleLayout = ({ data, ...props }: ArticleLayoutProps) => { const { mdx: { fields: { slug, modSlug }, - frontmatter: { title, langSwitcher, dbSwitcher, toc, tocDepth, codeStyle, wide }, + frontmatter: { title, langSwitcher, dbSwitcher, toc, tocDepth, codeStyle, wide, hideTitle }, body, parent, tableOfContents, @@ -39,6 +39,7 @@ const ArticleLayout = ({ data, ...props }: ArticleLayoutProps) => { part !== 'index') + tmp.hideTitle = hideTitle if (defaultCollapsed && location) { defaultCollapsed[part.toLowerCase()] = tmp.topLevel || tmp.staticLink ? null : getCollpaseState(modSlug, location) @@ -101,11 +106,13 @@ export const calculateTreeData = (edges: any, defaultCollapsed: any, location: a items: [], title, navTitle, + hideTitle, staticLink, duration, preview, deprecated, earlyaccess, + highlight, topLevel, hidePage, codeStyle, diff --git a/vercel.json b/vercel.json index c281af0860..bebbe5c5ec 100644 --- a/vercel.json +++ b/vercel.json @@ -475,502 +475,402 @@ "source": "/docs/guides/prisma-guides/prisma-migrate-guides", "destination": "/docs/guides/prisma-guides/add-prisma-migrate-to-a-project" }, - { "source": "/docs/guides/prisma-guides/prisma-migrate-guides/add-prisma-migrate-to-a-project", "destination": "/docs/guides/prisma-guides/add-prisma-migrate-to-a-project" }, - { "source": "/docs/concepts/components/prisma-client/distinct", "destination": "/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#select-distinct" }, - { "source": "/docs/concepts/components/prisma-client/configuring-the-prisma-client-api", "destination": "/docs/concepts/components/prisma-client/generating-prisma-client/customizing-the-prisma-client-api" }, - { "source": "/docs/concepts/components/prisma-client/constructor", "destination": "/docs/reference/api-reference/prisma-client-reference#prismaclient" }, - { "source": "/docs/concepts/components/prisma-client/field-selection", "destination": "/docs/concepts/components/prisma-client/select-fields" }, - { "source": "/docs/concepts/components/prisma-client/error-reference", "destination": "/docs/reference/api-reference/error-reference" }, - { "source": "/docs/concepts/components/prisma-client/sorting", "destination": "/docs/concepts/components/prisma-client/filtering-and-sorting" }, - { "source": "/docs/concepts/components/prisma-client/filtering", "destination": "/docs/concepts/components/prisma-client/filtering-and-sorting" }, - { "source": "/docs/concepts/components/prisma-client/aggregations", "destination": "/docs/concepts/components/prisma-client/aggregation-grouping-summarizing" }, - { "source": "/docs/concepts/components/prisma-client/working-with-json", "destination": "/docs/concepts/components/prisma-client/working-with-advanced-types" }, - { "source": "/docs/concepts/components/prisma-client/group-by", "destination": "/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#group-by-preview" }, - { "source": "/docs/concepts/components/prisma-client/advanced-usage-of-generated-types", "destination": "/docs/concepts/components/prisma-client/working-with-generated-types" }, - { "source": "/docs/concepts/components/preview-features/native-types/native-types-mappings", "destination": "/docs/reference/api-reference/prisma-schema-reference#model-field-scalar-types" }, - { "source": "/docs/concepts/components/preview-features/native-types", "destination": "/docs/concepts/components/prisma-schema/data-model#native-types-mapping" }, - { "source": "/docs/concepts/components/prisma-client/generating-prisma-client", "destination": "/docs/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client" }, - { "source": "/docs/concepts/components/prisma-client/generating-prisma-client/customizing-the-prisma-client-api", "destination": "/docs/concepts/components/prisma-client/working-with-prismaclient/use-custom-model-and-field-names" }, - { "source": "/docs/concepts/components/prisma-client/connection-management", "destination": "/docs/concepts/components/prisma-client/working-with-prismaclient/connection-management" }, - { "source": "/docs/concepts/components/prisma-client/logging", "destination": "/docs/concepts/components/prisma-client/working-with-prismaclient/logging" }, - { "source": "/docs/concepts/components/prisma-client/error-formatting", "destination": "/docs/concepts/components/prisma-client/working-with-prismaclient/error-formatting" }, - { "source": "/docs/concepts/components/prisma-client/deployment", "destination": "/docs/guides/deployment/deployment" }, - { "source": "/docs/concepts/components/prisma-migrate/prisma-migrate-flows", "destination": "/docs/concepts/components/prisma-migrate" }, - { "source": "/docs/guides/prisma-guides/seed-database", "destination": "/docs/guides/application-lifecycle/seed-database" }, - { "source": "/docs/guides/prisma-guides/add-prisma-migrate-to-a-project", "destination": "/docs/guides/database/developing-with-prisma-migrate/add-prisma-migrate-to-a-project" }, - { "source": "/docs/about/creating-bug-reports", "destination": "/docs/support/creating-bug-reports" }, - { "source": "/docs/concepts/components/prisma-client/working-with-generated-types", "destination": "/docs/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types" }, - { "source": "/docs/reference/utility-types-reference", "destination": "/docs/reference/api-reference/prisma-client-reference#prismavalidator" }, - { "source": "/docs/concepts/components/prisma-client/query-engine", "destination": "/docs/concepts/components/prisma-engines/query-engine" }, - { "source": "/docs/concepts/overview/under-the-hood", "destination": "/docs/concepts/components/prisma-engines" }, - { "source": "/docs/guides/application-lifecycle/add-prisma-migrate-to-a-project", "destination": "/docs/guides/database/developing-with-prisma-migrate/add-prisma-migrate-to-a-project" }, - { "source": "/docs/guides/deployment/patching-production", "destination": "/docs/guides/database/patching-production" }, - { "source": "/docs/guides/deployment/production-troubleshooting", "destination": "/docs/guides/database/production-troubleshooting" }, - { "source": "/docs/guides/application-lifecycle/:any*", "destination": "/docs/guides/database/:any*" }, - { "source": "/docs/guides/deployment/deploying-to-azure-functions", "destination": "/docs/guides/deployment/deployment-guides/deploying-to-azure-functions" }, - { "source": "/docs/guides/deployment/deploying-to-heroku", "destination": "/docs/guides/deployment/deployment-guides/deploying-to-heroku" }, - { "source": "/docs/guides/deployment/deploying-to-vercel", "destination": "/docs/guides/deployment/deployment-guides/deploying-to-vercel" }, - { "source": "/docs/guides/deployment/deploying-to-aws-lambda", "destination": "/docs/guides/deployment/deployment-guides/deploying-to-aws-lambda" }, - { "source": "/docs/guides/deployment/deploying-to-netlify", "destination": "/docs/guides/deployment/deployment-guides/deploying-to-netlify" }, - { "source": "/docs/guides/general-guides/database-workflows/cascading-deletes/:any*", "destination": "/docs/concepts/components/prisma-schema/relations/referential-actions" }, - { "source": "/docs/guides/database/advanced-database-tasks/cascading-deletes/:any*", "destination": "/docs/concepts/components/prisma-schema/relations/referential-actions" }, - { "source": "/docs/guides/general-guides/database-workflows/data-validation/:any*", "destination": "/docs/guides/database/advanced-database-tasks/data-validation/:any*" }, - { "source": "/docs/guides/general-guides/database-workflows/sql-views", "destination": "https://github.com/prisma/prisma/issues/678" }, - { "source": "/docs/guides/general-guides/database-workflows/sql-views-postgres", "destination": "https://github.com/prisma/prisma/issues/678" }, - { "source": "/docs/guides/database/advanced-database-tasks/sql-views-postgres", "destination": "https://github.com/prisma/prisma/issues/678" }, - { "source": "/docs/guides/general-guides/database-workflows/sql-views-mysql", "destination": "https://github.com/prisma/prisma/issues/678" }, - { "source": "/docs/guides/database/advanced-database-tasks/sql-views-mysql", "destination": "https://github.com/prisma/prisma/issues/678" }, - { "source": "/docs/guides/general-guides/database-workflows/unique-constraints-and-indexes", "destination": "/docs/concepts/components/prisma-schema/data-model#defining-a-unique-field" }, - { "source": "/docs/guides/general-guides/database-workflows/unique-constraints-and-indexes/mysql", "destination": "/docs/concepts/components/prisma-schema/data-model#defining-a-unique-field" }, - { "source": "/docs/guides/database/advanced-database-tasks/unique-constraints-and-indexes/postgresql", "destination": "/docs/concepts/components/prisma-schema/data-model#defining-a-unique-field" }, - { "source": "/docs/guides/general-guides/database-workflows/unique-constraints-and-indexes/sqlite", "destination": "/docs/concepts/components/prisma-schema/data-model#defining-a-unique-field" }, - { "source": "/docs/guides/general-guides/database-workflows/foreign-keys", "destination": "/docs/concepts/components/prisma-schema/relations#relational-databases" }, - { "source": "/docs/guides/general-guides/database-workflows/foreign-keys/mysql", "destination": "/docs/concepts/components/prisma-schema/relations#relational-databases" }, - { "source": "/docs/guides/general-guides/database-workflows/foreign-keys/postgresql", "destination": "/docs/concepts/components/prisma-schema/relations#relational-databases" }, - { "source": "/docs/guides/general-guides/database-workflows/foreign-keys/sqlite", "destination": "/docs/concepts/components/prisma-schema/relations#relational-databases" }, - { "source": "/docs/guides/prisma-guides/:any*", "destination": "/docs/guides/performance-and-optimization/:any*" }, - { "source": "/docs/mongodb", "destination": "/docs/concepts/database-connectors/mongodb" }, - { "source": "/docs/guides/database/developing-with-prisma-migrate/advanced-migrate-scenarios", "destination": "/docs/guides/database/developing-with-prisma-migrate/customizing-migrations" }, - { "source": "/docs/concepts/components/prisma-migrate/type-mapping", "destination": "/docs/concepts/components/prisma-migrate/supported-types-and-db-features" }, - { "source": "/docs/concepts/components/prisma-client/working-with-advanced-types", "destination": "/docs/concepts/components/prisma-client/working-with-fields" }, - { "source": "/docs/concepts/more/codemod", "destination": "/docs/guides/upgrade-guides/upgrading-versions/codemods" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/connect-your-database-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/using-prisma-migrate-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/install-prisma-client-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/install-prisma-client-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/querying-the-database-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/next-steps-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/next-steps-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/connect-your-database-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/introspection-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/install-prisma-client-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/install-prisma-client-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/querying-the-database-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/querying-the-database-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/next-steps-typescript-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/next-steps-typescript-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/connect-your-database-node-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/using-prisma-migrate-node-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/install-prisma-client-node-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/install-prisma-client-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/querying-the-database-node-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/next-steps-node-postgres", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/next-steps-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/connect-your-database-node-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/introspection-node-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/install-prisma-client-node-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/install-prisma-client-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/querying-the-database-node-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/querying-the-database-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/next-steps-node-postgres", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/next-steps-node-postgresql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/connect-your-database-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/using-prisma-migrate-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/install-prisma-client-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/install-prisma-client-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/querying-the-database-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/next-steps-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/next-steps-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/connect-your-database-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/introspection-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/install-prisma-client-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/install-prisma-client-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/querying-the-database-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/querying-the-database-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/next-steps-typescript-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/next-steps-typescript-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/connect-your-database-node-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/using-prisma-migrate-node-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/using-prisma-migrate-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/install-prisma-client-node-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/install-prisma-client-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/querying-the-database-node-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/querying-the-database-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/start-from-scratch/next-steps-node-mysql", "destination": "/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/next-steps-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/connect-your-database-node-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/introspection-node-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/introspection-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/install-prisma-client-node-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/install-prisma-client-node-mysql" }, - { "source": "/docs/getting-started/setup-prisma/add-to-existing-project/querying-the-database-node-mysql", "destination": "/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/querying-the-database-node-mysql" @@ -3812,8 +3712,8 @@ "destination": "/docs/accelerate" }, { - "source": "/docs/docs/data-platform/pulse", - "destination": "/docs/docs/pulse" + "source": "/docs/data-platform/pulse", + "destination": "/docs/pulse" }, { "source": "/docs/guides/upgrade-guides/upgrade-from-prisma-1/schema-incompatibilities-mysql", @@ -3834,6 +3734,78 @@ { "source": "/docs/accelerate/concepts", "destination": "/docs/accelerate" + }, + { + "source": "/docs/platform/classic-projects/data-proxy/:any*", + "destination": "/docs/accelerate" + }, + { + "source": "/docs/platform/classic-projects/platform/:any*", + "destination": "/docs/platform" + }, + { + "source": "/docs/platform/classic-projects/support", + "destination": "https://www.prisma.io/support" + }, + { + "source": "/docs/platform/classic-projects", + "destination": "/docs/platform" + }, + { + "source": "/docs/platform/platform-console/about", + "destination": "/docs/platform/about" + }, + { + "source": "/docs/platform/platform-console/concepts/workspaces", + "destination": "/docs/platform/concepts/workspaces" + }, + { + "source": "/docs/platform/platform-console/concepts/projects", + "destination": "/docs/platform/concepts/projects" + }, + { + "source": "/docs/platform/platform-console/maturity-levels", + "destination": "/docs/platform/maturity-levels" + }, + { + "source": "/docs/platform/platform-console/limits", + "destination": "/docs/platform/limits" + }, + { + "source": "/docs/platform/platform-console/support", + "destination": "/docs/platform/support" + }, + { + "source": "/docs/platform/platform-console", + "destination": "/docs/platform" + }, + { + "source": "/docs/orm/prisma-client/deployment/edge/deploy-to-cloudflare-workers", + "destination": "/docs/orm/prisma-client/deployment/edge/deploy-to-cloudflare" + }, + { + "source": "/docs/orm/prisma-client/deployment/module-bundlers", + "destination": "/docs/orm/prisma-client/deployment/module-bundlers" + }, + { + "source": "/docs/pulse/current-limitations", + "destination": "/docs/pulse/known-limitations", + "statusCode": 301 + }, + { + "source": "/docs/pulse/current-limitations#change-events-are-not-persisted", + "destination": "/docs/pulse/known-limitations#database-events-are-not-persisted", + "statusCode": 301 + }, + { + "source": "/pulse/current-limitations", + "destination": "/pulse/known-limitations", + "statusCode": 301 + }, + { + "source": "/pulse/getting-started#configuring-replication-slot", + "destination": "/pulse/database-setup/general-database-instructions#enable-logical-replication", + "statusCode": 301 } ] }