Skip to content

[6.8]feat: docs release #6898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9aa602d
[6.8]feat: docs release
ankur-arch May 9, 2025
dc2f8ac
Merge branch 'main' into DA-3386
ankur-arch May 9, 2025
ac45161
Merge branch 'main' into DA-3386
ankur-arch May 13, 2025
c991321
Update content/250-postgres/1100-integrations/500-vscode-agent.mdx
ankur-arch May 13, 2025
dd57944
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
9ff560b
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
d1f8564
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
b82768d
Update content/250-postgres/1100-integrations/500-vscode-agent.mdx
ankur-arch May 13, 2025
2db0cf3
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
449cc1a
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
ada2e39
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
41c3a07
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
78d18ce
feat: remove pglite docs
ankur-arch May 13, 2025
a4c4052
fix: clean up docs
ankur-arch May 13, 2025
f41fac9
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 13, 2025
6ccb06b
fix: correct word
ankur-arch May 13, 2025
4b4c82c
Update content/200-orm/500-reference/200-prisma-cli-reference.mdx
ankur-arch May 13, 2025
0cf666c
Merge branch 'main' into DA-3386
ankur-arch May 13, 2025
37c0d6d
Update content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx
ankur-arch May 14, 2025
82d3d7c
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 14, 2025
104f7cf
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 14, 2025
f840bf5
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 14, 2025
13fb33e
Update content/250-postgres/1100-integrations/500-vscode-agent.mdx
ankur-arch May 14, 2025
da76e68
Update content/200-orm/500-reference/200-prisma-cli-reference.mdx
ankur-arch May 14, 2025
7f9fbae
feat: add arguments
ankur-arch May 14, 2025
9d0225e
fix: add more arguments
ankur-arch May 14, 2025
6e2db1f
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 14, 2025
24bff6c
Update content/250-postgres/300-database/550-local-development.mdx
ankur-arch May 14, 2025
0dcbdf4
Merge branch 'main' into DA-3386
ankur-arch May 14, 2025
275fdd7
feat: early access
ankur-arch May 15, 2025
556f5a8
Merge branch 'main' into DA-3386
ankur-arch May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ const prisma = new PrismaClient()

> **Note**: If you're using [driver adapters](/orm/overview/databases/database-drivers#driver-adapters), you can import from the location spefified in your generator's `output` path directly, e.g. `./src/generated/prisma`. No need to import from `./src/generated/prisma/edge`.

For Deno, you can import Prisma Client as follows:

```ts file=lib/prisma.ts
import { PrismaClient } from './generated/prisma/deno/edge.ts'

const prisma = new PrismaClient()
// use `prisma` in your application to read and write data in your DB
```

The import path will depend on the custom `output` specified in Prisma Client's [`generator`](/orm/reference/prisma-schema-reference#generator) block in your Prisma schema.

### 4. Use Prisma Client to send queries to your database

Once you have instantiated `PrismaClient`, you can start sending queries in your code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ This command:
- Creates a `prisma` directory containing a `schema.prisma` file for your database models.
- Creates a `.env` file with your `DATABASE_URL` (e.g., for Prisma Postgres it should have something similar to `DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhbGciOiJIUzI..."`).

Edit the `prisma/schema.prisma` file to define a `Log` model, add a custom `output` path and enable the `deno` preview feature flag:
Edit the `prisma/schema.prisma` file to define a `Log` model, add a custom `output` path and [the `prisma-client` generator](/orm/prisma-schema/overview/generators#prisma-client-early-access) with `deno` as the `runtime`:

```prisma file=schema.prisma highlight=3-4,12-23;add showLineNumbers
generator client {
// delete-start
provider = "prisma-client-js"
// delete-end
//add-start
previewFeatures = ["deno"]
output = "../generated/client"
provider = "prisma-client"
output = "../generated/prisma"
runtime = "deno"
//add-end
}

Expand All @@ -79,13 +82,11 @@ enum Level {
//add-end
```

:::note
Then, install Prisma Client:

To use Deno, you need to add the preview feature flag `deno` to the `generator` block of your `schema.prisma` file.

Deno also requires you to generate Prisma Client in a custom location. You can enable this with the `output` parameter in the `generator` block.

:::
```terminal
deno install npm:@prisma/client
```

Then, install [the Client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) required to use Prisma Postgres:

Expand Down Expand Up @@ -121,7 +122,7 @@ You can now create a local Deno application. Create `index.ts` in the root folde
```ts file=index.ts
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { withAccelerate } from "npm:@prisma/extension-accelerate";
import { PrismaClient } from "./generated/client/deno/edge.ts";
import { PrismaClient } from "./generated/prisma/client.ts";

const prisma = new PrismaClient().$extends(withAccelerate());

Expand Down Expand Up @@ -208,6 +209,7 @@ Use the GitHub repository to add your application to Deno Deploy:
1. Go to [https://dash.deno.com/](https://dash.deno.com/).
1. Select a GitHub organization or user and then select a repository.
1. Select a production branch and select **Fresh (Automatic)** mode so that Deno Deploy can deploy every time you push a change to the repository.
1. In the **Build Step** add `deno run -A npm:prisma generate` to generate the Prisma Client.
1. Select `index.ts` as the entry point to your project.
1. Click `Create & Deploy`.

Expand All @@ -227,7 +229,7 @@ Add the following code in your `index.ts` file:
```ts file=index.ts
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { withAccelerate } from "npm:@prisma/extension-accelerate";
import { PrismaClient } from "./generated/client/deno/edge.ts";
import { PrismaClient } from "./generated/prisma/client.ts";

const prisma = new PrismaClient().$extends(withAccelerate());

Expand Down
47 changes: 47 additions & 0 deletions content/200-orm/500-reference/200-prisma-cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,53 @@ A file to define environment variables for your project:
DATABASE_URL="mysql://user:password@localhost:3306/mydb"
```

### `dev`

The `dev` command starts a local Prisma Postgres database that you can run Prisma ORM commands against. It is useful for development and testing purposes and also allows you to switch to [Prisma Postgres](/postgres) in production easily. You can learn more about the local Prisma Postgres database [in this section](/postgres/database/local-development).

#### Arguments

| Argument | Required | Description | Default |
| --------------------- | -------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
| `--port` (or `-p`) | No | Main port number the local Prisma Postgres HTTP server will listen on. | `51213` |
| `--db-port` (or `-P`) | No | Port number the local Prisma Postgres database server will listen on. | `51214` |
| `--shadow-db-port` | No | Port number the shadow database server will listen on. | `51215` |
| `--debug` | No | Enable debug logging. | `false` |



#### Examples

**Run `prisma dev`**

<CodeWithResult expanded={true}>

<cmd>

```terminal
prisma dev
```

</cmd>

<cmdResult>

```code no-copy wrap
Starting Prisma Dev...


Great Success!

To connect to your local Prisma Postgres database via Prisma ORM, use the following connection string:

DATABASE_URL="prisma+postgres://localhost:51213/?api_key=__API_KEY__"

```

</cmdResult>

</CodeWithResult>

### `generate`

The `generate` command generates assets like Prisma Client based on the [`generator`](/orm/prisma-schema/overview/generators) and [`data model`](/orm/prisma-schema/data-model/models) blocks defined in your `prisma/schema.prisma` file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ The following [Preview](/orm/more/releases#preview) feature flags are available
| [`metrics`](/orm/prisma-client/observability-and-logging/metrics) | [3.15.0](https://github.com/prisma/prisma/releases/tag/3.15.0) | [Submit feedback](https://github.com/prisma/prisma/issues/13579) |
| [`multiSchema`](https://github.com/prisma/prisma/issues/1122#issuecomment-1231773471) | [4.3.0](https://github.com/prisma/prisma/releases/tag/4.3.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15077) |
| [`postgresqlExtensions`](/orm/prisma-schema/postgresql-extensions) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15835) |
| [`deno`](/orm/prisma-client/deployment/edge/deploy-to-deno-deploy) | [4.5.0](https://github.com/prisma/prisma/releases/tag/4.5.0) | [Submit feedback](https://github.com/prisma/prisma/issues/15844) |
| [`views`](/orm/prisma-schema/data-model/views) | [4.9.0](https://github.com/prisma/prisma/releases/tag/4.9.0) | [Submit feedback](https://github.com/prisma/prisma/issues/17335) |
| `driverAdapters` | [5.4.0](https://github.com/prisma/prisma/releases/tag/5.4.0) | [Submit feedback](https://github.com/prisma/prisma/issues/3108) |
| `relationJoins` | [5.7.0](https://github.com/prisma/prisma/releases/tag/5.7.0) | [Submit feedback](https://github.com/prisma/prisma/discussions/22288) |
Expand All @@ -30,7 +29,7 @@ The following [Preview](/orm/more/releases#preview) feature flags are available
| `strictUndefinedChecks` | [5.20.0](https://github.com/prisma/prisma/releases/tag/5.20.0) | [Submit feedback](https://github.com/prisma/prisma/discussions/25271) |
| [`fullTextSearchPostgres`](/orm/prisma-client/queries/full-text-search) | [6.0.0](https://github.com/prisma/prisma/releases/tag/6.0.0) | [Submit feedback](https://github.com/prisma/prisma/issues/25773) |
| [`prisma-client`](/orm/prisma-schema/overview/generators#prisma-client-early-access) | [6.6.0](https://pris.ly/release/6.6.0) | [Submit feedback](https://github.com/prisma/prisma/issues/25773) |
| `queryCompiler` | [6.7.0](https://pris.ly/release/6.7.0) | [Submit feedback](https://github.com/prisma/prisma/issues/tbd) |
| `queryCompiler` | [6.7.0](https://pris.ly/release/6.7.0) | [Submit feedback](https://github.com/prisma/prisma/issues/) |

To enable a Preview feature, [add the feature flag to the `generator` block](#enabling-a-prisma-client-preview-feature) in your `schema.prisma` file. [Share your feedback on all Preview features on GitHub](https://github.com/prisma/prisma/issues/3108).

Expand Down
234 changes: 234 additions & 0 deletions content/200-orm/800-more/350-ai-tools/400-github-copilot.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
---
title: 'GitHub Copilot'
metaTitle: 'Prisma ORM with GitHub Copilot'
metaDescription: 'Learn about the features available with GitHub Copilot and Prisma ORM, plus best practices and tips.'
tocDepth: 3
toc: true
---

GitHub Copilot is an AI coding assistant that speeds up your Prisma ORM workflows, so you spend less time on boilerplate and more on data modeling, querying, and collaboration. With the GitHub Copilot extension in your editor, you can:

- Get Prisma-aware code suggestions as you edit your schema or invoke the client.
- Chat with Copilot about modeling patterns, troubleshoot queries, or explore migration strategies.
- Run common Prisma CLI commands (e.g. `prisma migrate dev`, `prisma db push`) via Copilot's command-palette interface.
- Scaffold Prisma schema models and generate Prisma Client code and run migrations directly from the Copilot chat interface.

GitHub Copilot allows you to query the official docs via the [**Prisma for GitHub Copilot** extension](https://github.com/apps/prisma-for-github-copilot) and also perform automated [actions in VS Code Agent mode](/postgres/integrations/vscode-agent), such as scaffolding a Prisma schema, running seeds scripts, and creating a production-ready Prisma Postgres database.

## Query Prisma docs with the Prisma for GitHub Copilot extension

The [Prisma for GitHub Copilot extension](https://github.com/apps/prisma-for-github-copilot) lets you fetch Prisma documentation directly in GitHub Copilot Chat. You can look up schema syntax, client methods, migration commands, and more from your editor.

### How to enable the extension

1. Install the **Prisma for Copilot** from the GitHub Marketplace.
2. Ensure [GitHub Copilot Chat is installed](https://docs.github.com/en/copilot/using-github-copilot/copilot-chat/asking-github-copilot-questions-in-your-ide) and active in your code editor.
3. Open a file in your workspace and launch Copilot Chat.
4. In chat, prefix your question with the `@prisma-for-copilot` keyword:

```
@prisma-for-copilot How do I define a one-to-many relation?
```

1. Install the [Prisma for GitHub Copilot](https://github.com/apps/prisma-for-github-copilot) extension.
2. Open your IDE.
3. Install the [GitHub Copilot Chat extension](https://docs.github.com/en/copilot/managing-copilot/configure-personal-settings/installing-the-github-copilot-extension-in-your-environment).
4. Open Copilot Chat and switch to [**Ask** mode](https://code.visualstudio.com/docs/copilot/chat/chat-ask-mode).
5. Ask: "`@prisma-for-github-copilot` How do I define a one-to-many relation?" (If the `@prisma-for-github-copilot` namespace doesn't show up after a few seconds, reload the chat.)
6. When prompted, authorize the Prisma app in your browser, then return to the chat.
7. After returning to the chat, resend the question.
8. Copilot returns the answer pulled straight from the Prisma docs.

## Use GitHub Copilot's agent features

GitHub Copilot Chat offers an **Agent** mode in VS Code that can run Prisma commands. You can use the agent chat to:

- Run and inspect migrations.
- Generate Prisma Client code.
- Create a new Prisma Postgres database and update your `.env` file.

You can type `Create a database named test-db and add its connection string to the .env file.` in the Copilot chat, and it will automatically create a new database named `test-db` and add the connection string to your `.env` file. To learn more about this, visit our [VS Code agent mode documentation](/postgres/integrations/vscode-agent).

## Customize GitHub Copilot with `copilot-instructions.md`

You can tailor Copilot Chat's behavior in your repository by [adding a `.github/copilot-instructions.md` file](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot). This file injects your guidelines into every Copilot Chat session.

<details>
<summary>Example `.github/copilot-instructions.md` for Prisma</summary>

```text
# GitHub Copilot Instructions for Prisma Workspace

## General Guidelines

1. **Language**: English only.
2. **Types**: Declare explicit types; avoid `any`.
3. **Comments**: Use JSDoc for public methods and classes.
4. **Exports**: One export per file.
5. **Naming**:

* **Classes/interfaces** → `PascalCase`
* **Variables/functions** → `camelCase`
* **Files/directories** → `kebab-case`
* **Constants** → `UPPERCASE`
* **Boolean flags** → verb-based (e.g., `isLoading`)

---

## Prisma-Specific Guidelines

### 1. Data Modeling

* **Domain-driven model names**: keep them singular (e.g. `User`, `OrderItem`).
* **Field naming**: use `camelCase` for fields (e.g. `createdAt`, `deletedAt`).
* **IDs & keys**:

```prisma
model Post {
id Int @id @default(autoincrement())
uuid String @unique @default(uuid())
}
/```
* **Composite keys & uniques**:

```prisma
@@id([userId, role])
@@unique([email, tenantId])
/```
* **Enums & constrained values**: leverage `enum` for fixed domains.
* **Soft deletes & audit**:

```prisma
model Base {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
}
/```

### 2. Indexing & Constraints

* **Single-column indexes** for frequent lookups:

```prisma
@@index([email])
/```
* **Compound indexes** for multi-field filters/sorts:

```prisma
@@index([status, createdAt])
/```
* **Full-text search** (Postgres-only):

```prisma
@@index([title, content], type: Brin) // or Gin for JSONB
/```

### 3. Migrations

* **Descriptive names**: `npx prisma migrate dev --name add-order-totals`
* **Idempotent steps**: avoid imperative SQL in migrations.
* **Shadow database**: enable in CI to catch drift.
* **Never edit** migration SQL after it’s applied to any environment.

### 4. Client Instantiation & Connection Management

* **Singleton pattern**

```ts
// prisma.ts
import { PrismaClient } from '@prisma/client';
export const prisma = global.prisma || new PrismaClient();
if (process.env.NODE_ENV !== 'production') global.prisma = prisma;
/```

### 5. Transactions & Batch Operations

* **Multi-step atomicity**:

```ts
const result = await prisma.$transaction([
prisma.user.create({ data: { /*…*/ } }),
prisma.order.create({ data: { /*…*/ } }),
]);
/```
* **Interactive transactions** for long-running flows.
* **Bulk writes**: chunk large inserts/updates to avoid timeouts.

### 6. Precise Queries & Performance

* **Select only needed fields**:

```ts
await prisma.user.findUnique({
where: { id },
select: { id: true, email: true },
});
/```
* **Avoid N+1**: use `include` or batch `findMany` with `where: { id: { in: [...] } }` or use database joins in prisma.
* Use **Cursor-based pagination**

### 7. Raw Queries & Client Extensions

* **Raw SQL** when necessary, safely:

```ts
const users = await prisma.$queryRaw`SELECT * FROM "User" WHERE email = ${email}`;
/```
* **Sanitize inputs** with `Prisma.sql` for complex interpolations.
* **Client extensions**: use preview feature `clientExtensions` to add common helper methods.

### 8. Error Handling

* **Catch specific errors**:

```ts
try {
// …
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
// P2002: Unique constraint
}
}
/```
* **Wrap in service-level errors** to add context before bubbling up.

### 9. Testing

* **In-memory DB** (SQLite) or **Testcontainers** for integration tests.
* **Mock Prisma Client** for pure unit tests via `jest.mock()` or similar.

### 10. Logging, Monitoring & Metrics

* **Enable query logging** in dev:

```ts
new PrismaClient({ log: ['query', 'warn', 'error'] });
/```
* **APM integration** (Datadog, Sentry) – capture latency, errors.
* **Client extensions** for metrics: create extensions that wrap calls to emit timing and telemetry instead of middleware.

### 11. Security & Best Practices

* **Never expose** raw Prisma client in HTTP controllers—wrap in a service layer.
* **Validate inputs** (e.g. with Zod) before any DB operation.
* **Least privilege** DB users: use separate roles for migrations vs. runtime.
* **Rotate credentials** and load from secure vault (AWS Secrets Manager, etc.).

### 12. Environment & Configuration

* **Centralize `DATABASE_URL`** and connection settings in `.env`.
* **Pin preview features** in `schema.prisma`:

```prisma
generator client {
previewFeatures = ["clientExtensions", "interactiveTransactions"]
}
/```
* **Version pinning**: match CLI and client versions in `package.json`.

```

</details>

Place this file at the root of your repository under `.github/`. Copilot Chat automatically applies these rules to every conversation in your project.
Loading
Loading