From 7baa25ec2ca0b8003da4d0f4b28c63aaa500a1bb Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:47:01 +0600 Subject: [PATCH 01/10] feat: promote Management API to GA DC-4847 --- .../100-introduction/230-management-api.mdx | 50 +++++++++++++------ static/_redirects | 2 + 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/content/250-postgres/100-introduction/230-management-api.mdx b/content/250-postgres/100-introduction/230-management-api.mdx index 987af41b83..6137249594 100644 --- a/content/250-postgres/100-introduction/230-management-api.mdx +++ b/content/250-postgres/100-introduction/230-management-api.mdx @@ -2,7 +2,6 @@ title: 'Management API' metaTitle: 'Prisma Postgres: Management API Reference' metaDescription: 'Management API reference documentation for Prisma Postgres.' -sidebar_class_name: early-access-badge --- ## Overview @@ -228,7 +227,12 @@ Create a new database. { "region": "us-east-1", "name": "My Database", - "isDefault": false + "isDefault": false, + // fromDatabase is needed in case of restoring from backup + "fromDatabase": { + "id": "databaseId", + "backupId": "string" + } } ``` - **Responses**: @@ -319,23 +323,39 @@ Retrieve database backups. - `401 Unauthorized` - `404 Not Found` -#### `POST /databases/{databaseId}/backups/{backupId}/restore` +### Integrations -Restore a backup to a new database. +#### `GET /workspaces/{workspaceId}/integrations` + +Returns integrations for the given workspace. - **Path parameters**: - - `databaseId`: Database ID - - `backupId`: Database backup ID -- **Request body**: - ```json - { - "targetDatabaseName": "New DB Name" - } - ``` + - `workspaceId`: Workspace ID +- **Query parameters**: + - `cursor` (optional): Cursor for pagination + - `limit` (optional, default: 100): Limit number of results - **Responses**: - - `202 Accepted`: Restore initiated - - `401 Unauthorized` - - `409 Conflict` + - `200 OK`: List of integrations with details: + - `id`: Integration ID + - `createdAt`: Creation timestamp + - `scopes`: Array of granted scopes + - `client`: Object containing `id`, `name`, `createdAt` + - `createdByUser`: Object containing `id`, `email`, `displayName` + - `401 Unauthorized`: Missing or invalid authentication token + - `404 Not Found`: Workspace not found + + +#### `DELETE /workspaces/{workspaceId}/integrations/{clientId}` + +Revokes the integration tokens with the given client ID. + +- **Path parameters**: + - `workspaceId`: Workspace ID (e.g. `wksp_1234`) + - `clientId`: Integration client ID (e.g. `itgr_5678`) +- **Responses**: + - `204 No Content`: Integration tokens revoked successfully + - `401 Unauthorized`: Missing or invalid authentication token + - `404 Not Found`: Workspace or integration not found ### Misc diff --git a/static/_redirects b/static/_redirects index a02a3f17e3..2c5707daee 100644 --- a/static/_redirects +++ b/static/_redirects @@ -564,6 +564,8 @@ /postgres/database/api-reference/management-api /docs/postgres/introduction/management-api /postgres/database/error-reference /docs/postgres/database/api-reference/error-reference /postgres/integrations/vscode-extension /postgres/integrations/vscode +/postgres/introduction/management-api#post-databasesdatabaseidbackupsbackupidrestore /postgres/introduction/management-api#post-projectsprojectiddatabases + ### Dynamic redirects ### /faq/* https://v1.prisma.io/docs/1.34/faq/:splat /understand-prisma/* https://v1.prisma.io/docs/1.34/understand-prisma/:splat From 5bd7329cab508bb585f17b5bb02a7233587ae358 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 19:49:12 +0600 Subject: [PATCH 02/10] fix: update concistency --- content/250-postgres/100-introduction/230-management-api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/250-postgres/100-introduction/230-management-api.mdx b/content/250-postgres/100-introduction/230-management-api.mdx index 6137249594..278e944b9e 100644 --- a/content/250-postgres/100-introduction/230-management-api.mdx +++ b/content/250-postgres/100-introduction/230-management-api.mdx @@ -327,7 +327,7 @@ Retrieve database backups. #### `GET /workspaces/{workspaceId}/integrations` -Returns integrations for the given workspace. +Retrieve integrations for the given workspace. - **Path parameters**: - `workspaceId`: Workspace ID From 39f5878728b4f081f35866a30d661d337c4967bb Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 20:31:05 +0600 Subject: [PATCH 03/10] feat: add note about typedsql DC-4849 --- .../050-overview/500-databases/200-database-drivers.mdx | 6 ++++++ .../200-prisma-client/150-using-raw-sql/100-typedsql.mdx | 6 ++++++ 2 files changed, 12 insertions(+) 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 839ba9ea3d..dfbd15e995 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 @@ -236,3 +236,9 @@ export default defineNuxtConfig({ // ... }) ``` + +### Driver adapters and TypedSQL + +[TypedSQL](/orm/prisma-client/using-raw-sql/typedsql) lets you write fully type-safe SQL queries that integrate directly with Prisma Client. This feature is useful if you want the flexibility of writing SQL while still benefiting from Prisma's type-safety. + +You can also use driver adapters together with TypedSQL to connect through JavaScript database drivers. TypedSQL works with all supported driver adapters except `@prisma/adapter-better-sqlite3`. For SQLite support, use [`@prisma/adapter-libsql`](https://www.npmjs.com/package/@prisma/adapter-libsql) instead. \ No newline at end of file diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx index 58084c74fe..9050511163 100644 --- a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx +++ b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx @@ -24,6 +24,12 @@ To start using TypedSQL in your Prisma project, follow these steps: previewFeatures = ["typedSql"] } ``` + + :::tip[Using driver adapters with TypedSQL] + + If you are deploying Prisma in serverless or edge environments, you can use [driver adapters](/orm/overview/databases/database-drivers#driver-adapters) to connect through JavaScript database drivers. Driver adapters are compatible with TypedSQL, with the exception of `@prisma/adapter-better-sqlite3`. For SQLite support, use [`@prisma/adapter-libsql`](https://www.npmjs.com/package/@prisma/adapter-libsql) instead. All other driver adapters are supported. + + ::: 1. Create a `sql` directory inside your `prisma` directory. This is where you'll write your SQL queries. From c6fb34e0b6a972312fe3626eb273471ef08c72c2 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 21:09:48 +0600 Subject: [PATCH 04/10] feat: add underlyingDriver docs DC-4848 --- .../201-serverless/300-deploy-to-vercel.mdx | 21 +++++++++++++++++++ .../301-edge/485-deploy-to-vercel.mdx | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) 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 60d7928198..3a1b9d4a3a 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 @@ -132,3 +132,24 @@ When you use a Function-as-a-Service provider, like Vercel Serverless functions, You can use [Accelerate](/accelerate) for connection pooling or [Prisma Postgres](/postgres), which has built-in connection pooling, to reduce your Prisma Client bundle size, and to avoid cold starts. For more information on connection management for serverless environments, refer to our [connection management guide](/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). + +### Using Prisma ORM with Vercel Fluid + +[Fluid compute](https://vercel.com/fluid) is a compute model from Vercel that combines the flexibility of serverless with the stability of servers, making it ideal for dynamic workloads such as streaming data and AI APIs. Vercel's Fluid compute [supports both edge and Node.js runtimes](https://vercel.com/docs/fluid-compute#available-runtime-support). A common challenge in traditional serverless platforms is leaked database connections when functions are suspended and pools can't close idle connections. Fluid provides [`attachDatabasePool`](https://vercel.com/blog/the-real-serverless-compute-to-database-connection-problem-solved) to ensure idle connections are released before a function is suspended. + +Use `attachDatabasePool` together with [Prisma's driver adapters](/orm/overview/databases/database-drivers) to safely manage connections in Fluid: + +```ts +import { Pool } from 'pg' +import { attachDatabasePool } from '@vercel/functions' +import { PrismaPg } from '@prisma/adapter-pg' +import { PrismaClient } from '@prisma/client' + +const pool = new Pool({ connectionString: process.env.POSTGRES_URL }) + +attachDatabasePool(pool) + +const prisma = new PrismaClient({ + adapter: new PrismaPg(pool), +}) +``` \ No newline at end of file diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx index 06edfa8c9a..6508d91b92 100644 --- a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx @@ -504,3 +504,24 @@ 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. + +### Using Prisma ORM with Vercel Fluid + +[Fluid compute](https://vercel.com/fluid) is a compute model from Vercel that combines the flexibility of serverless with the stability of servers, making it ideal for dynamic workloads such as streaming data and AI APIs. Vercel's Fluid compute [supports both edge and Node.js runtimes](https://vercel.com/docs/fluid-compute#available-runtime-support). A common challenge in traditional serverless platforms is leaked database connections when functions are suspended and pools can't close idle connections. Fluid provides [`attachDatabasePool`](https://vercel.com/blog/the-real-serverless-compute-to-database-connection-problem-solved) to ensure idle connections are released before a function is suspended. + +Use `attachDatabasePool` together with [Prisma's driver adapters](/orm/overview/databases/database-drivers) to safely manage connections in Fluid: + +```ts +import { Pool } from 'pg' +import { attachDatabasePool } from '@vercel/functions' +import { PrismaPg } from '@prisma/adapter-pg' +import { PrismaClient } from '@prisma/client' + +const pool = new Pool({ connectionString: process.env.POSTGRES_URL }) + +attachDatabasePool(pool) + +const prisma = new PrismaClient({ + adapter: new PrismaPg(pool), +}) +``` From e5ae067755c25a9f0e68d4ea444bef391834f73a Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 23:39:02 +0600 Subject: [PATCH 05/10] fix: add AI guardrails docs --- .../200-prisma-cli-reference.mdx | 30 +++++++++++++++++ .../800-more/350-ai-tools/100-cursor.mdx | 32 ++++++++++++++++++- .../1100-integrations/400-mcp-server.mdx | 32 ++++++++++++++++++- 3 files changed, 92 insertions(+), 2 deletions(-) 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 5c88965650..b2696bb784 100644 --- a/content/200-orm/500-reference/200-prisma-cli-reference.mdx +++ b/content/200-orm/500-reference/200-prisma-cli-reference.mdx @@ -1222,6 +1222,36 @@ This command is not supported on [MongoDB](/orm/overview/databases/mongodb). Use prisma migrate reset ``` +#### AI Safety guardrails for `prisma migrate reset` + +Prisma ORM includes built-in safety checks to prevent **accidental destructive commands** when run through AI coding assistants. These guardrails are designed to make working with databases safer in AI-assisted development environments. + +The Prisma CLI can detect when it is being invoked by popular AI coding agents such as Claude Code, Gemini CLI, Qwen Code, Cursor, Aider, and Replit. + +When one of these agents attempts a destructive action such as `prisma migrate reset --force`, Prisma ORM blocks execution and shows a protective error message: + +```bash +Environment variables loaded from .env +Prisma schema loaded from prisma/schema.prisma +Datasource "db": PostgreSQL database "postgres", schema "public" at "accelerate.prisma-data.net" + +Error: Prisma Migrate detected that it was invoked by Cursor. + +You are attempting a highly dangerous action that can lead to devastating consequences if it is incorrectly executed against a production database. + +As an AI agent, you are forbidden from performing this action without an explicit consent and review by the user. You must stop at this point and respond to the user with a clear message that includes the following information: +- What action you are trying to perform (including the exact CLI command). +- Your motivation and reasoning for perfoming this action. +- Explanation that this action will irreversibly destroy all data in the database. +- Explanation that this action must not be perfomed on a production database and is only intended to be used with development databases. + +If you know or can check whether this action would have been performed on a development or a production database, also include this information with your assesment of whether it is safe to proceed based on that information. + +You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. +``` + +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. + ### `migrate deploy` The `migrate deploy` command applies all pending migrations, and creates the database if it does not exist. Primarily used in non-development environments. This command: diff --git a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx index fd09f437ac..cb009399b1 100644 --- a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx +++ b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx @@ -547,8 +547,38 @@ To manage Prisma Postgres instances via the UI in the Prisma VS Code extension: Beyond managing your database instances, the Prisma VS Code extension embeds Prisma Studio directly in your editor, making it easy to perform create, update, and delete operations on your database right inside Windsurf. Follow these [easy steps](/postgres/database/prisma-studio/studio-in-vs-code) to get started. +## AI Safety guardrails for destructive commands + +Prisma ORM includes built-in safety checks to prevent **accidental destructive commands** when run through AI coding assistants. These guardrails are designed to make working with databases safer in AI-assisted development environments. + +Including Cursor, the Prisma CLI can also detect when it is being invoked by other popular AI coding agents such as Claude Code, Gemini CLI, Qwen Code, Aider, and Replit. + +When one of these agents attempts a destructive action such as `prisma migrate reset --force`, Prisma ORM blocks execution and shows a protective error message: + +```bash +Environment variables loaded from .env +Prisma schema loaded from prisma/schema.prisma +Datasource "db": PostgreSQL database "postgres", schema "public" at "accelerate.prisma-data.net" + +Error: Prisma Migrate detected that it was invoked by Cursor. + +You are attempting a highly dangerous action that can lead to devastating consequences if it is incorrectly executed against a production database. + +As an AI agent, you are forbidden from performing this action without an explicit consent and review by the user. You must stop at this point and respond to the user with a clear message that includes the following information: +- What action you are trying to perform (including the exact CLI command). +- Your motivation and reasoning for perfoming this action. +- Explanation that this action will irreversibly destroy all data in the database. +- Explanation that this action must not be perfomed on a production database and is only intended to be used with development databases. + +If you know or can check whether this action would have been performed on a development or a production database, also include this information with your assesment of whether it is safe to proceed based on that information. + +You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. +``` + +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. + ## Additional resources In summary, using Cursor with Prisma simplifies your workflow, from generating schemas and queries to writing seed scripts. By following this guide, you can save time, reduce errors, and focus on building your application. -Learn more about Cursor in their [official documentation](https://docs.cursor.com/context/@-symbols/basic). \ No newline at end of file +Learn more about Cursor in their [official documentation](https://docs.cursor.com/context/@-symbols/basic). diff --git a/content/250-postgres/1100-integrations/400-mcp-server.mdx b/content/250-postgres/1100-integrations/400-mcp-server.mdx index a54c92ddb3..b806b60168 100644 --- a/content/250-postgres/1100-integrations/400-mcp-server.mdx +++ b/content/250-postgres/1100-integrations/400-mcp-server.mdx @@ -421,4 +421,34 @@ async def main(): # Run the async main function asyncio.run(main()) -``` \ No newline at end of file +``` + +## AI Safety guardrails for destructive commands + +Prisma ORM includes built-in safety checks to prevent **accidental destructive commands** when run through AI coding assistants. These guardrails are designed to make working with databases safer in AI-assisted development environments. + +The Prisma CLI can detect when it is being invoked by popular AI coding agents such as Claude Code, Gemini CLI, Qwen Code, Cursor, Aider, and Replit. + +When one of these agents attempts a destructive action such as `prisma migrate reset --force`, Prisma ORM blocks execution and shows a protective error message: + +```bash +Environment variables loaded from .env +Prisma schema loaded from prisma/schema.prisma +Datasource "db": PostgreSQL database "postgres", schema "public" at "accelerate.prisma-data.net" + +Error: Prisma Migrate detected that it was invoked by Cursor. + +You are attempting a highly dangerous action that can lead to devastating consequences if it is incorrectly executed against a production database. + +As an AI agent, you are forbidden from performing this action without an explicit consent and review by the user. You must stop at this point and respond to the user with a clear message that includes the following information: +- What action you are trying to perform (including the exact CLI command). +- Your motivation and reasoning for perfoming this action. +- Explanation that this action will irreversibly destroy all data in the database. +- Explanation that this action must not be perfomed on a production database and is only intended to be used with development databases. + +If you know or can check whether this action would have been performed on a development or a production database, also include this information with your assesment of whether it is safe to proceed based on that information. + +You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. +``` + +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. From 19f10b492b26bc749246332eaa7f6b8104882120 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Mon, 25 Aug 2025 23:57:01 +0600 Subject: [PATCH 06/10] feat: add simplified runtime options for prisma-client DC-4868 --- .../100-prisma-schema/10-overview/03-generators.mdx | 8 +++++++- .../200-orm/500-reference/100-prisma-schema-reference.mdx | 2 +- .../250-postgres/100-introduction/220-npx-create-db.mdx | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) 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 94b41b6373..7fb8c5c822 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 @@ -212,11 +212,17 @@ Below are the options for the `prisma-client` generator: | **Option** | **Default** | **Description** | | ------------------------ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `output` (**required**) | | Directory where Prisma Client is generated, e.g. `../src/generated/prisma`. | -| `runtime` | `nodejs` | Target runtime environment.
Supported values:
`nodejs` (alias `node`), `deno`, `bun`, `deno-deploy`, `workerd` (alias `cloudflare`), `edge-light` (alias `vercel`), `react-native`. | +| `runtime` | `nodejs` | Target runtime environment.
Supported values:
`nodejs`, `deno`, `bun`, `workerd` (alias `cloudflare`), `vercel-edge` (alias `edge-light`), `react-native`. | | `moduleFormat` | Inferred from environment | Module format (`esm` or `cjs`). Determines whether `import.meta.url` or `__dirname` is used. | | `generatedFileExtension` | `ts` | File extension for generated TypeScript files (`ts`, `mts`, `cts`). | | `importFileExtension` | Inferred from environment | File extension used in **import statements**. Can be `ts`, `mts`, `cts`, `js`, `mjs`, `cjs`, or empty (for bare imports). | +:::note + +`nodejs`, `deno`, and `bun` all map to the same internal codepath but are preserved as separate user-facing values for clarity. + +::: + ### Output splitting and importing types The `prisma-client-js` generator used to generate all typings into a single `index.d.ts` file, which could lead to [slowing down editors](https://github.com/prisma/prisma/issues/4807) (e.g. breaking auto-complete) with large schemas. 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 350a6a3cbf..2ba0bde051 100644 --- a/content/200-orm/500-reference/100-prisma-schema-reference.mdx +++ b/content/200-orm/500-reference/100-prisma-schema-reference.mdx @@ -187,7 +187,7 @@ A `generator` block accepts the following fields: | `provider` | **Yes** | `prisma-client` | Describes which [generator](/orm/prisma-schema/overview/generators) to use. This can point to a file that implements a generator or specify a built-in generator directly. | | `output` | **Yes** | String (file path) | Determines the location for the generated client, [learn more](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path). | | `previewFeatures` | No | List of Enums | Use intellisense to see list of currently available Preview features (`Ctrl+Space` in Visual Studio Code) **Default**: none | -| `runtime` | No | Enum (`nodejs` (alias `node`), `deno`, `bun`, `deno-deploy`, `workerd` (alias `cloudflare`), `edge-light` (alias `vercel`), `react-native`) | Target runtime environment. **Default**: `nodejs` | +| `runtime` | No | Enum (`nodejs`, `deno`, `bun`, `workerd` (alias `cloudflare`), `vercel-edge` (alias `edge-light`), `react-native`) | Target runtime environment. **Default**: `nodejs` | | `moduleFormat` | No | Enum (`esm` or `cjs`) | Determines whether the generated code supports ESM (uses `import`) or CommonJS (uses `require(...)`) modules. We always recommend `esm` unless you have a good reason to use `cjs`. **Default**: Inferred from environment. | | `generatedFileExtension` | No | Enum (`ts` or `mts` or `cts`) | File extension for generated TypeScript files. **Default**: `ts` | | `importFileExtension` | No | Enum (`ts`,`mts`,`cts`,`js`,`mjs`,`cjs`, empty (for bare imports)) | File extension used in import statements **Default**: Inferred from environment. | diff --git a/content/250-postgres/100-introduction/220-npx-create-db.mdx b/content/250-postgres/100-introduction/220-npx-create-db.mdx index 176e89eefa..bd3929baf0 100644 --- a/content/250-postgres/100-introduction/220-npx-create-db.mdx +++ b/content/250-postgres/100-introduction/220-npx-create-db.mdx @@ -146,6 +146,7 @@ Here are the CLI flags for the `npx create-db` command: |---------------|-----------|----------------------------------------------------------------------------------------------| | `--region` | `-r` | Specify a region.
**Available regions:** `ap-southeast-1`, `ap-northeast-1`, `eu-central-1`, `eu-west-3`, `us-east-1`, `us-west-1` | | `--interactive` | `-i` | Run in interactive mode (select region from a list). | +| `--json` | `-j` | Output machine-readable JSON and exit. | | `--help` | `-h` | Show this help message. | From 0c7f4f7b77f40853796fd7a1831dafd0d821a931 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 26 Aug 2025 00:11:26 +0600 Subject: [PATCH 07/10] feat: add oauth and management api changes --- .../100-introduction/230-management-api.mdx | 14 ++++++++ content/800-guides/240-management-api.mdx | 36 ++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/content/250-postgres/100-introduction/230-management-api.mdx b/content/250-postgres/100-introduction/230-management-api.mdx index 278e944b9e..001be409f9 100644 --- a/content/250-postgres/100-introduction/230-management-api.mdx +++ b/content/250-postgres/100-introduction/230-management-api.mdx @@ -49,6 +49,8 @@ To adhere to the Bearer Token Authentication, you need to format your `Authoriza Authorization: Bearer $TOKEN ``` +#### Creating a service token + You can create a service token to use the Management API like this: 1. Open the [Prisma Console](https://console.prisma.io/). @@ -57,6 +59,18 @@ You can create a service token to use the Management API like this: 4. Click **New Service Token**. 5. Copy the generated token and store it in a safe location for future use. +#### Creating an OAuth credentials + +To obtain a client ID and client secret, go through this flow: + +1. Open the [Prisma Console](https://console.prisma.io). +1. Click the 🧩 **Integrations** tab in the sidenav. +1. In the **Published Applications** section, click **New Application** button to start the flow for creating a new OAuth app. +1. Enter a **Name**, **Description** and **Callback URL** for your OAuth app. +1. Click **Continue**. + +On the next screen, you can access and save the client ID and client secret for your OAuth app. + ### Example ```terminal diff --git a/content/800-guides/240-management-api.mdx b/content/800-guides/240-management-api.mdx index 4166906718..f392b76428 100644 --- a/content/800-guides/240-management-api.mdx +++ b/content/800-guides/240-management-api.mdx @@ -21,7 +21,7 @@ The two Cloudflare Workers in this guide are just reference examples. You would Similarly, the `npx create-db` CLI is a simple demo. In your product, you can trigger the same API calls from your own UI or onboarding flows to create a seamless experience for your users. ::: -## Core Concepts +## Core concepts Before diving into implementation, let's clarify the main concepts involved in the Management API integration: @@ -29,24 +29,36 @@ Before diving into implementation, let's clarify the main concepts involved in t - **Projects vs Databases**: A project is a container that can hold multiple databases. You can use this to organize databases you create e.g. by user. Projects can then be transferred to users, including all databases they contain. - **Authentication**: All API requests require authentication. As a partner, you use OAuth2 to obtain integration tokens (for your app) and facilitate secure transfers to your users. - **Tokens**: There are two main types of tokens: - - **Integration Token**: Issued to your partner integration, scoped to provision and manage databases on your own workspace. - - **User Access Token**: Obtained via OAuth2 when a user authenticates with your app, scoped to the user's workspace and can be used to transfer database ownership to the user's workspace. + - **Service token**: Issued to your partner integration, scoped to provision and manage databases on your own workspace. + - **OAuth 2 access token**: Obtained via OAuth2 when a user authenticates with your app, scoped to the user's workspace and can be used to transfer database ownership to the user's workspace. ## How to become a partner To use the Prisma Postgres Management API, you first need to set up as a partner: 1. **Request access to the Management API**: Contact the Prisma team from the [Prisma Partners page](https://www.prisma.io/partners) to request access to the Management API. You will be guided through the onboarding process. -2. **Obtain OAuth credentials**: Once approved, you will receive an OAuth client ID and client secret. These credentials are required to authenticate your integration and enable secure database transfers for your users. +2. **Obtain OAuth credentials**: You can obtain your OAuth credentials in the [Prisma Console](https://console.prisma.io). See the [next section](#get-oauth-credentials) for details. For a complete list of available endpoints and details on request/response formats, see the [Prisma Management API documentation](/postgres/introduction/management-api). -## Provisioning a Database as a Partner +## Get OAuth credentials + +To obtain a client ID and client secret, you need go through this flow: + +1. Open the [Prisma Console](https://console.prisma.io). +1. Click the 🧩 **Integrations** tab in the sidenav. +1. In the **Published Applications** section, click **New Application** button to start the flow for creating a new OAuth app. +1. Enter a **Name**, **Description** and **Callback URL** for your OAuth app. +1. Click **Continue**. + +On the next screen, you can access and save the client ID and client secret for your OAuth app. + +## Provisioning a database as a Partner To provision a new Prisma Postgres database for your users as a partner, follow these steps: 1. **Gather required information**: Prepare the necessary details for provisioning, such as region, database name, and any other options your application requires. This information may come from user input or be determined by your application logic. -2. **Authenticate your integration**: Use your integration token (obtained via OAuth2) to authenticate API requests. This token authenticates your app as an approved partner. +2. **Authenticate your integration**: Use your service token to authenticate API requests from your backend. This token authenticates your app as an approved partner. 3. **Send a database provisioning request**: Make a `POST` request to the Management API endpoint to create a new project with a default database. For example: ```ts @@ -54,7 +66,7 @@ const prismaResponse = await fetch('https://api.prisma.io/v1/projects', { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer `, + Authorization: `Bearer `, }, body: JSON.stringify({ region, name }), }); @@ -64,11 +76,11 @@ const prismaResponse = await fetch('https://api.prisma.io/v1/projects', { 5. **(Optional) Store project metadata**: You may want to associate the `project_id` with your user in your own database for future reference. -## Database Claim Flow +## Database claim flow Once a database is provisioned, you may want to transfer ownership to your user at a later point so they can manage it in their own Prisma workspace and go beyond the free database usage limits. This is done via the claim flow, which consists of three main steps: -### Overview: How the Claim Flow Works +### Overview: How the claim flow works When a user wants to claim a database, your app will: @@ -78,7 +90,7 @@ When a user wants to claim a database, your app will: This ensures the transfer is secure and only the intended user can claim the database. -### 1. Triggering the Claim Flow +### 1. Triggering the claim flow When your user wants to take ownership of a database you provisioned for them, they need to transfer it to their own Prisma Postgres workspace. This gives them full control over it. @@ -102,11 +114,11 @@ const authUrl = `https://auth.prisma.io/authorize?${authParams.toString()}`; // Redirect the user to authUrl ``` -### 2. Authenticating the User +### 2. Authenticating the user The user will be prompted to log in (if not already authenticated) and select the workspace where they want to claim the database. After successful authentication and workspace selection, Prisma Auth will redirect back to your callback endpoint with a `code` and `state` (and, in some cases, a `project_id`). -### 3. Finishing the Claim Flow +### 3. Finishing the claim flow Your backend should now: From 388682ed6e04b74e2d8c436a5a88d9f9fa2f58c6 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 26 Aug 2025 00:17:02 +0600 Subject: [PATCH 08/10] fix: mentions of edge-ight --- .../200-orm/100-prisma-schema/10-overview/03-generators.mdx | 2 +- content/800-guides/350-authjs-nextjs.mdx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 7fb8c5c822..de201617f2 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 @@ -266,7 +266,7 @@ To see what the new `prisma-client` generator looks like in practice, check out | [`nextjs-starter-webpack`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack) | Next.js 15 | Webpack | Node.js | n/a | | [`nextjs-starter-turbopack`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-turbopack) | Next.js 15 | Turbopack (alpha) | Node.js | n/a | | [`nextjs-starter-webpack-monorepo`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-monorepo) | Next.js 15 | Webpack | Node.js | pnpm | -| [`nextjs-starter-webpack-with-middleware`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-with-middleware) | Next.js 15 | Webpack | Node.js (main pages), Vercel Edge Light (middleware) | n/a | +| [`nextjs-starter-webpack-with-middleware`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-with-middleware) | Next.js 15 | Webpack | Node.js (main pages), `vercel-edge` (middleware) | n/a | | [`nextjs-starter-webpack-turborepo`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nextjs-starter-webpack-turborepo) | Next.js 15 | Webpack | Node.js | turborepo | | [`react-router-starter-nodejs`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/react-router-starter-nodejs) | React Router 7 | Vite 6 | Node.js | n/a | | [`react-router-starter-cloudflare-workerd`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/react-router-starter-cloudflare-workerd) | React Router 7 | | | n/a | diff --git a/content/800-guides/350-authjs-nextjs.mdx b/content/800-guides/350-authjs-nextjs.mdx index 8ec7c3d9e9..1e1051d8af 100644 --- a/content/800-guides/350-authjs-nextjs.mdx +++ b/content/800-guides/350-authjs-nextjs.mdx @@ -87,7 +87,7 @@ This will create: ### 2.2. Define your Prisma Schema -In the `prisma/schema.prisma` file, swap the provider to `prisma-client` and add the runtime `edge-light` to the generator: +In the `prisma/schema.prisma` file, swap the provider to `prisma-client` and add the runtime `vercel-edge` to the generator: ```prisma file=prisma/schema.prisma generator client { @@ -95,7 +95,7 @@ generator client { provider = "prisma-client" output = "../app/generated/prisma" //add-next-line - runtime = "edge-light" + runtime = "vercel-edge" } datasource db { From acc57c7b3960af80ad2ae5e0ee82a09e52315afb Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 26 Aug 2025 12:18:25 +0600 Subject: [PATCH 09/10] fix: polishing the text] --- .../500-deployment/201-serverless/300-deploy-to-vercel.mdx | 2 +- .../500-deployment/301-edge/485-deploy-to-vercel.mdx | 2 +- content/200-orm/500-reference/200-prisma-cli-reference.mdx | 2 +- content/200-orm/800-more/350-ai-tools/100-cursor.mdx | 2 +- content/250-postgres/100-introduction/230-management-api.mdx | 4 +++- content/250-postgres/1100-integrations/400-mcp-server.mdx | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) 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 3a1b9d4a3a..b1c4086ab8 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 @@ -133,7 +133,7 @@ You can use [Accelerate](/accelerate) for connection pooling or [Prisma Postgres For more information on connection management for serverless environments, refer to our [connection management guide](/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). -### Using Prisma ORM with Vercel Fluid +## Using Prisma ORM with Vercel Fluid [Fluid compute](https://vercel.com/fluid) is a compute model from Vercel that combines the flexibility of serverless with the stability of servers, making it ideal for dynamic workloads such as streaming data and AI APIs. Vercel's Fluid compute [supports both edge and Node.js runtimes](https://vercel.com/docs/fluid-compute#available-runtime-support). A common challenge in traditional serverless platforms is leaked database connections when functions are suspended and pools can't close idle connections. Fluid provides [`attachDatabasePool`](https://vercel.com/blog/the-real-serverless-compute-to-database-connection-problem-solved) to ensure idle connections are released before a function is suspended. diff --git a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx index 6508d91b92..5f7f4f98d5 100644 --- a/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx +++ b/content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx @@ -505,7 +505,7 @@ 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. -### Using Prisma ORM with Vercel Fluid +## Using Prisma ORM with Vercel Fluid [Fluid compute](https://vercel.com/fluid) is a compute model from Vercel that combines the flexibility of serverless with the stability of servers, making it ideal for dynamic workloads such as streaming data and AI APIs. Vercel's Fluid compute [supports both edge and Node.js runtimes](https://vercel.com/docs/fluid-compute#available-runtime-support). A common challenge in traditional serverless platforms is leaked database connections when functions are suspended and pools can't close idle connections. Fluid provides [`attachDatabasePool`](https://vercel.com/blog/the-real-serverless-compute-to-database-connection-problem-solved) to ensure idle connections are released before a function is suspended. 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 b2696bb784..d85901e951 100644 --- a/content/200-orm/500-reference/200-prisma-cli-reference.mdx +++ b/content/200-orm/500-reference/200-prisma-cli-reference.mdx @@ -1250,7 +1250,7 @@ If you know or can check whether this action would have been performed on a deve You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. ``` -To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the `PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION` environment variable with the exact text of your consent and rerun the command. ### `migrate deploy` diff --git a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx index cb009399b1..2ded8dd4df 100644 --- a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx +++ b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx @@ -575,7 +575,7 @@ If you know or can check whether this action would have been performed on a deve You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. ``` -To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the `PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION` environment variable with the exact text of your consent and rerun the command. ## Additional resources diff --git a/content/250-postgres/100-introduction/230-management-api.mdx b/content/250-postgres/100-introduction/230-management-api.mdx index 001be409f9..16215c26d5 100644 --- a/content/250-postgres/100-introduction/230-management-api.mdx +++ b/content/250-postgres/100-introduction/230-management-api.mdx @@ -242,13 +242,15 @@ Create a new database. "region": "us-east-1", "name": "My Database", "isDefault": false, - // fromDatabase is needed in case of restoring from backup "fromDatabase": { "id": "databaseId", "backupId": "string" } } ``` + :::note + Use `fromDatabase` only when creating the database from an existing one or a backup. + ::: - **Responses**: - `201 Created` - `400 Default database already exists` diff --git a/content/250-postgres/1100-integrations/400-mcp-server.mdx b/content/250-postgres/1100-integrations/400-mcp-server.mdx index b806b60168..4d3a2d1bfa 100644 --- a/content/250-postgres/1100-integrations/400-mcp-server.mdx +++ b/content/250-postgres/1100-integrations/400-mcp-server.mdx @@ -451,4 +451,4 @@ If you know or can check whether this action would have been performed on a deve You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. ``` -To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable with the exact text of your consent and rerun the command. +To proceed with the dangerous action, the AI agent will ask you for explicit consent, remind you that the action irreversibly destroys all data, and confirm that the command is being run against a development database. Once you clearly confirm, the AI will set the `PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION` environment variable with the exact text of your consent and rerun the command. From d2ae3dd467c8f942f2032f8e704031d448d5ed10 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:42:58 +0600 Subject: [PATCH 10/10] fix: refine coderabbit comments --- .../100-prisma-schema/10-overview/03-generators.mdx | 2 +- .../150-using-raw-sql/100-typedsql.mdx | 4 ++-- content/200-orm/800-more/350-ai-tools/100-cursor.mdx | 6 +++--- .../100-introduction/230-management-api.mdx | 12 ++++++------ content/800-guides/240-management-api.mdx | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) 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 de201617f2..8b1e1337c4 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 @@ -271,7 +271,7 @@ To see what the new `prisma-client` generator looks like in practice, check out | [`react-router-starter-nodejs`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/react-router-starter-nodejs) | React Router 7 | Vite 6 | Node.js | n/a | | [`react-router-starter-cloudflare-workerd`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/react-router-starter-cloudflare-workerd) | React Router 7 | | | n/a | | [`nuxt3-starter-nodejs`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/nuxt3-starter-nodejs) | Nuxt 3 | Vite 6 | Node.js | n/a | -| [`deno-deploy`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/deno-deploy) | None | None | Deno 2 | n/a | +| [`deno`](https://github.com/prisma/prisma-examples/tree/latest/generator-prisma-client/deno-deploy) | None | None | Deno 2 | n/a | ## Community generators diff --git a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx index 9050511163..36c85247bf 100644 --- a/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx +++ b/content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx @@ -104,7 +104,7 @@ To pass arguments to your TypedSQL queries, you can use parameterized queries. T ``` - In SQLite, there are a number of different placeholders you can use. Postional placeholders (`$1`, `$2`, etc.), general placeholders (`?`), and named placeholders (`:minAge`, `:maxAge`, etc.) are all available. For this example, we'll use named placeholders `:minAge` and `:maxAge`: + In SQLite, there are a number of different placeholders you can use. Positional placeholders (`$1`, `$2`, etc.), general placeholders (`?`), and named placeholders (`:minAge`, `:maxAge`, etc.) are all available. For this example, we'll use named placeholders `:minAge` and `:maxAge`: ```sql title="prisma/sql/getUsersByAge.sql" SELECT id, name, age @@ -202,7 +202,7 @@ The format of argument type definitions is the same regardless of the database e :::note -Manually argument type definitions are not supported for array arguments. For these arguments, you will need to rely on the type inference provided by TypedSQL. +Manual argument type definitions are not supported for array arguments. For these arguments, you will need to rely on the type inference provided by TypedSQL. ::: diff --git a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx index 2ded8dd4df..9d8275a356 100644 --- a/content/200-orm/800-more/350-ai-tools/100-cursor.mdx +++ b/content/200-orm/800-more/350-ai-tools/100-cursor.mdx @@ -566,11 +566,11 @@ You are attempting a highly dangerous action that can lead to devastating conseq As an AI agent, you are forbidden from performing this action without an explicit consent and review by the user. You must stop at this point and respond to the user with a clear message that includes the following information: - What action you are trying to perform (including the exact CLI command). -- Your motivation and reasoning for perfoming this action. +- Your motivation and reasoning for performing this action. - Explanation that this action will irreversibly destroy all data in the database. -- Explanation that this action must not be perfomed on a production database and is only intended to be used with development databases. +- Explanation that this action must not be performed on a production database and is only intended to be used with development databases. -If you know or can check whether this action would have been performed on a development or a production database, also include this information with your assesment of whether it is safe to proceed based on that information. +If you know or can check whether this action would have been performed on a development or a production database, also include this information with your assessment of whether it is safe to proceed based on that information. You must ask the user if they want to proceed with this action. If they explicitly consent, you may rerun this command with PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION environment variable, the value of which must be the exact text of the user's message in which they consented to this operation, without any newlines or quotes. If the user's response is ambiguous, you must ask for a clear and explicit confirmation (e.g., "yes") before proceeding. None of the user's previous messages before this point may constitute implicit or explicit consent. ``` diff --git a/content/250-postgres/100-introduction/230-management-api.mdx b/content/250-postgres/100-introduction/230-management-api.mdx index 16215c26d5..a5a65cd0f5 100644 --- a/content/250-postgres/100-introduction/230-management-api.mdx +++ b/content/250-postgres/100-introduction/230-management-api.mdx @@ -8,7 +8,7 @@ metaDescription: 'Management API reference documentation for Prisma Postgres.' This page covers the Prisma Management API which enables you to programmatically manage [platform](/platform/about) resources (e.g. projects or Prisma Postgres instances) in [Prisma Console](https://console.prisma.io). -:::tip OpenApi +:::tip OpenAPI An interactive [**OpenAPI 3.1 specification** is available here](https://api.prisma.io/v1/swagger-editor), where you can explore endpoints, request/response bodies, and detailed examples. ::: @@ -59,17 +59,17 @@ You can create a service token to use the Management API like this: 4. Click **New Service Token**. 5. Copy the generated token and store it in a safe location for future use. -#### Creating an OAuth credentials +#### Creating OAuth credentials To obtain a client ID and client secret, go through this flow: 1. Open the [Prisma Console](https://console.prisma.io). 1. Click the 🧩 **Integrations** tab in the sidenav. -1. In the **Published Applications** section, click **New Application** button to start the flow for creating a new OAuth app. -1. Enter a **Name**, **Description** and **Callback URL** for your OAuth app. +1. In the **Published Applications** section, click the **New Application** button to start creating a new OAuth app. +1. Enter a **Name**, **Description**, and **Callback URL** for your OAuth app. 1. Click **Continue**. -On the next screen, you can access and save the client ID and client secret for your OAuth app. +On the next screen, copy and store the client ID and client secret for your OAuth app in a secure location. ### Example @@ -313,7 +313,7 @@ Create a new connection string. - `401 Unauthorized` - `404 Not Found` -#### `/connections/{id}` +#### `DELETE /connections/{id}` Delete a connection string. diff --git a/content/800-guides/240-management-api.mdx b/content/800-guides/240-management-api.mdx index f392b76428..7b80dbdd66 100644 --- a/content/800-guides/240-management-api.mdx +++ b/content/800-guides/240-management-api.mdx @@ -25,13 +25,13 @@ Similarly, the `npx create-db` CLI is a simple demo. In your product, you can tr Before diving into implementation, let's clarify the main concepts involved in the Management API integration: -- **Management API**: A set of endpoints that allow to programmatically provision and manage Prisma Postgres databases. +- **Management API**: A set of endpoints that allow you to programmatically provision and manage Prisma Postgres databases. - **Projects vs Databases**: A project is a container that can hold multiple databases. You can use this to organize databases you create e.g. by user. Projects can then be transferred to users, including all databases they contain. -- **Authentication**: All API requests require authentication. As a partner, you use OAuth2 to obtain integration tokens (for your app) and facilitate secure transfers to your users. +- **Authentication**: All API requests require authentication. As a partner, you authenticate provisioning calls with a service token for your workspace, and use OAuth 2 to obtain an access token for the user during the claim flow. - **Tokens**: There are two main types of tokens: - **Service token**: Issued to your partner integration, scoped to provision and manage databases on your own workspace. - - **OAuth 2 access token**: Obtained via OAuth2 when a user authenticates with your app, scoped to the user's workspace and can be used to transfer database ownership to the user's workspace. - + - **OAuth 2 access token**: Obtained via OAuth 2 when a user authenticates with your app; it is scoped to the user's workspace and used to transfer project/database ownership to that workspace. + ## How to become a partner To use the Prisma Postgres Management API, you first need to set up as a partner: @@ -146,7 +146,7 @@ const transferResponse = await fetch(`https://api.prisma.io/v1/projects/${projec method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${YOUR_INTEGRATION_TOKEN}`, + Authorization: `Bearer ${PRISMA_SERVICE_TOKEN}`, }, body: JSON.stringify({ recipientAccessToken: tokenData.access_token }), });