Skip to content

Commit fe702ef

Browse files
harshil1712windsurf-bot[bot]Oxyjun
authored
[D1] Update Prisma tutorial (#22856)
* Minor fixes to Prisma tutorial * Update src/content/docs/d1/tutorials/d1-and-prisma-orm/index.mdx Co-authored-by: windsurf-bot[bot] <189301087+windsurf-bot[bot]@users.noreply.github.com> * Update src/content/docs/d1/tutorials/d1-and-prisma-orm/index.mdx Co-authored-by: windsurf-bot[bot] <189301087+windsurf-bot[bot]@users.noreply.github.com> * Update src/content/docs/d1/tutorials/d1-and-prisma-orm/index.mdx Co-authored-by: Jun Lee <[email protected]> --------- Co-authored-by: windsurf-bot[bot] <189301087+windsurf-bot[bot]@users.noreply.github.com> Co-authored-by: Jun Lee <[email protected]>
1 parent 42de3a5 commit fe702ef

File tree

1 file changed

+13
-8
lines changed
  • src/content/docs/d1/tutorials/d1-and-prisma-orm

1 file changed

+13
-8
lines changed

src/content/docs/d1/tutorials/d1-and-prisma-orm/index.mdx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
updated: 2025-05-16
2+
updated: 2025-06-03
33
difficulty: Beginner
44
content_type: Tutorial
55
pcx_content_type: tutorial
@@ -83,14 +83,11 @@ Open your `schema.prisma` file and adjust the `generator` block to reflect as fo
8383
```diff
8484
generator client {
8585
provider = "prisma-client-js"
86-
+ previewFeatures = ["driverAdapters"]
86+
output = "../src/generated/prisma"
87+
previewFeatures = ["driverAdapters"]
8788
}
8889
```
8990

90-
:::note
91-
Do not specify an `output` destination in the `generator client` block. Instead, allow prisma to generate the files in the default output path.
92-
:::
93-
9491
### 3. Create your D1 database
9592

9693
In this step, you will set up your D1 database. You can create a D1 database via the [Cloudflare dashboard](https://dash.cloudflare.com), or via `wrangler`. This tutorial will use the `wrangler` CLI.
@@ -129,6 +126,8 @@ name = "prisma-d1-example"
129126
main = "src/index.ts"
130127
compatibility_date = "2024-03-20"
131128
compatibility_flags = ["nodejs_compat"]
129+
[observability]
130+
enabled = true
132131

133132
[[d1_databases]]
134133
binding = "DB" # i.e. available in your Worker on env.DB
@@ -146,7 +145,13 @@ Next, you will create a database table in the database to send queries to D1 usi
146145

147146
[Prisma Migrate](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/overview) does not support D1 yet, so you cannot follow the default migration workflows using `prisma migrate dev` or `prisma db push`.
148147

149-
However, D1 has a [migration system](/d1/reference/migrations), and the Prisma CLI provides tools that allow you to generate SQL statements for schema changes. In the following steps, you will use D1's migration system and the Prisma CLI to create and run a migration against your database.
148+
:::note
149+
150+
Prisma Migrate for D1 is currently in Early Access. If you want to try it out, you can follow the instructions on the [Prisma documentation](https://www.prisma.io/docs/orm/overview/databases/cloudflare-d1#using-prisma-migrate-via-a-driver-adapter-in-prismaconfigts-early-access).
151+
152+
:::
153+
154+
D1 uses [migrations](/d1/reference/migrations) for managing schema changes, and the Prisma CLI can help generate the necessary SQL for those updates. In the steps below, you'll use both tools to create and apply a migration to your database.
150155

151156
First, create a new migration using `wrangler`:
152157

@@ -259,7 +264,7 @@ To query your database from the Worker using Prisma ORM, you need to:
259264
Open `src/index.ts` and replace the entire content with the following:
260265
261266
```ts
262-
import { PrismaClient } from "@prisma/client";
267+
import { PrismaClient } from './generated/prisma/';
263268
import { PrismaD1 } from "@prisma/adapter-d1";
264269
265270
export interface Env {

0 commit comments

Comments
 (0)