Skip to content

Commit cc410ce

Browse files
cf worker guide changes (#7309)
* og image added and minor updates * Optimised images with calibre/image-actions * Trigger CI/CD pipeline --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 70cd03e commit cc410ce

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

content/800-guides/410-cloudflare-workers.mdx

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This will create:
6969

7070
Cloudflare Workers needs Node.js compatibility enabled to work with Prisma. Add the `nodejs_compat` compatibility flag to your `wrangler.jsonc`:
7171

72-
```jsonc file=wrangler.jsonc
72+
```json file=wrangler.jsonc
7373
{
7474
"name": "prisma-cloudflare-worker",
7575
"main": "src/index.ts",
@@ -80,33 +80,9 @@ Cloudflare Workers needs Node.js compatibility enabled to work with Prisma. Add
8080
}
8181
```
8282

83-
### 2.3. Add environment types to Prisma config
8483

85-
Add the `Env` interface to your `prisma.config.ts` to provide type safety for environment variables:
84+
### 2.3. Define your Prisma Schema
8685

87-
```typescript file=prisma.config.ts
88-
import "dotenv/config";
89-
import { defineConfig, env } from "prisma/config";
90-
91-
//add-start
92-
export interface Env {
93-
DATABASE_URL: string;
94-
}
95-
//add-end
96-
97-
import { defineConfig, env } from 'prisma/config';
98-
export default defineConfig({
99-
schema: 'prisma/schema.prisma',
100-
migrations: {
101-
path: 'prisma/migrations',
102-
},
103-
datasource: {
104-
url: env('DATABASE_URL'),
105-
},
106-
});
107-
```
108-
109-
### 2.4. Define your Prisma schema
11086

11187
In the `prisma/schema.prisma` file, add the following `User` model and set the runtime to `cloudflare`:
11288

@@ -131,9 +107,15 @@ model User {
131107
//add-end
132108
```
133109

110+
:::note
111+
112+
Both the `cloudflare` and `workerd` runtimes are supported. Read more about runtimes [here](/orm/prisma-schema/overview/generators#field-reference).
113+
114+
:::
115+
134116
This creates a `User` model with an auto-incrementing ID, email, and name.
135117

136-
### 2.5. Configure Prisma scripts
118+
### 2.4. Configure Prisma scripts
137119

138120
Add the following scripts to your `package.json` to work with Prisma in the Cloudflare Workers environment:
139121

@@ -150,7 +132,7 @@ Add the following scripts to your `package.json` to work with Prisma in the Clou
150132
}
151133
```
152134

153-
### 2.6. Run migrations and generate Prisma Client
135+
### 2.5. Run migrations and generate Prisma Client
154136

155137
Now, run the following command to create the database tables:
156138

54.5 KB
Loading

0 commit comments

Comments
 (0)