You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/d1/tutorials/d1-and-prisma-orm/index.mdx
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
updated: 2025-05-16
2
+
updated: 2025-06-03
3
3
difficulty: Beginner
4
4
content_type: Tutorial
5
5
pcx_content_type: tutorial
@@ -83,14 +83,11 @@ Open your `schema.prisma` file and adjust the `generator` block to reflect as fo
83
83
```diff
84
84
generator client {
85
85
provider = "prisma-client-js"
86
-
+ previewFeatures = ["driverAdapters"]
86
+
output = "../src/generated/prisma"
87
+
previewFeatures = ["driverAdapters"]
87
88
}
88
89
```
89
90
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
-
94
91
### 3. Create your D1 database
95
92
96
93
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"
129
126
main = "src/index.ts"
130
127
compatibility_date = "2024-03-20"
131
128
compatibility_flags = ["nodejs_compat"]
129
+
[observability]
130
+
enabled = true
132
131
133
132
[[d1_databases]]
134
133
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
146
145
147
146
[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`.
148
147
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.
150
155
151
156
First, create a new migration using `wrangler`:
152
157
@@ -259,7 +264,7 @@ To query your database from the Worker using Prisma ORM, you need to:
259
264
Open `src/index.ts` and replace the entire content with the following:
260
265
261
266
```ts
262
-
import { PrismaClient } from "@prisma/client";
267
+
import { PrismaClient } from './generated/prisma/';
0 commit comments