From cfb36a9ecd6041d04fb310c27ba39dd43cb729c4 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 12 Feb 2025 17:10:13 +0600 Subject: [PATCH 01/30] feat: add blog on using prisma postgres with workers --- .../index.mdx | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx new file mode 100644 index 000000000000000..1271e3673da99f1 --- /dev/null +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -0,0 +1,224 @@ +--- +updated: 2025-02-12 +difficulty: Beginner +content_type: 📝 Tutorial +pcx_content_type: tutorial +title: Setup Prisma Postgres database using Workers +languages: + - TypeScript + - SQL + - Prisma ORM + - PostgreSQL +--- + +[Prisma Postgres](https://www.prisma.io/postgres) is a managed-PostgreSQL database that has built-in connection pooling, caching, real-time subscriptions, and query optimization recommendations. + +In this tutorial, you will learn how to: + +- Set up a Cloudflare workers project with [Prisma ORM](https://www.prisma.io/docs). +- Create a Prisma Postgres instance from the CLI. +- Query the database from Workers. +- Deploy the worker to Cloudflare. + +## Prerequisites + +To follow this guide, ensure you have the following: + +- Node.js `v18.18` or higher installed. +- An active [Cloudflare account](https://dash.cloudflare.com/). +- A basic familiarity with installing and using command-line interface (CLI) applications. + +## 1. Create a new Worker project + +Begin by using [C3](/pages/get-started/c3/) to create a Worker project in the command line: + +```sh +npm create cloudflare@latest prisma-postgres-worker -- --type=hello-world --ts=true --git=true --deploy=false +``` + +Then navigate into your project: + +```sh +cd ./prisma-postgres-worker +``` + +Your initial `src/index.ts` file contains a simple request handler: + +```ts title="src/index.ts" +export default { + async fetch(request, env, ctx): Promise { + return new Response("Hello World!"); + }, +} satisfies ExportedHandler; +``` + +## 2. Setup Prisma in your project + +In this step, we set up Prisma ORM with a Prisma Postgres database using the CLI. Then we'll create and execute helper scripts to create tables in our database and generate a Prisma client to query it. + +### 2.1. Install required dependencies + +Install Prisma CLI as a dev dependency: + +```sh +npm install prisma --save-dev +``` + +Install the [Prisma Accelerate client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) as that's required for Prisma Postgres: + +```sh +npm i @prisma/extension-accelerate +``` + +Install the [`dotenv-cli` package](https://www.npmjs.com/package/dotenv-cli) to load environment variables from `.dev.vars`: + +```sh +npm i -D dotenv-cli +``` + +### 2.2. Create a Prisma Postgres database and initialize Prisma + +Initialize Prisma in your application: + +```sh +npx prisma@latest init --db +``` + +If you don't have an account yet, or if you are not logged in, the command will prompt you to log in using one of the available authentication providers. A browser window will open so you can log in or create an account. Return to the CLI after you have completed this step. + +Once logged in (or if you were already logged in), the CLI will prompt you to select a project name and a database region. + +After the command runs successfully, it will create: + +- A `prisma` folder containing `schema.prisma`, where you will define your database schema. +- An `.env` file in the project root, which will contain the Prisma Postgres database url `DATABASE_URL=`. + +You will use a `.dev.vars` file instead of the created `.env` file. + +### 2.3. Prepare environment variables + +Create a `.dev.vars` file in the root of your application and copy the `DATABASE_URL` from the `.env` file. You can also do this via the CLI: + +```sh +cp .env .dev.vars +``` + +Then, you can remove the `.env` file. + +### 2.4. Apply database schema changes + +Open the `schema.prisma` file in the `prisma` folder and add the following `User` model to your database: + +```prisma title="prisma/schema.prisma" +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + email String + name String +} +``` + +Next, add the following helper scripts to the `scripts` section of your `package.json`: + +```json title="package.json" +"scripts": { + "migrate": "dotenv -e .dev.vars -- npx prisma migrate dev", + "generate": "dotenv -e .dev.vars -- npx prisma generate --no-engine", + "studio": "dotenv -e .dev.vars -- npx prisma studio", + // Additional worker scripts... +} +``` + +Run the migration script to apply changes to the database: + +```sh +npm run migrate +``` + +When prompted, provide a name for the migration (e.g., `init`). + +After these steps are complete, Prisma ORM is fully set up and connected to your Prisma Postgres database. + +## 3. Develop the application + +Modify the `src/index.ts` file with the following code: + +```ts title="src/index.ts" +import { PrismaClient } from "@prisma/client/edge"; +import { withAccelerate } from "@prisma/extension-accelerate"; + +export interface Env { + DATABASE_URL: string; +} + +export default { + async fetch(request, env, ctx): Promise { + const prisma = new PrismaClient({ + datasourceUrl: env.DATABASE_URL, + }).$extends(withAccelerate()); + + await prisma.user.create({ + data: { + email: `Jon${Math.ceil(Math.random() * 1000)}@gmail.com`, + name: "Jon Doe", + }, + }); + + const userCount = await prisma.user.count(); + + return new Response(`Number of users in the database: ${userCount}`); + }, +} satisfies ExportedHandler; +``` + +Run the development server: + +```sh +npm run dev +``` + +Visit `https://localhost:8787` to see your app in action. + +## 4. Deploy the application to Cloudflare + +Use the [`npx wrangler secret put` command](/workers/configuration/secrets/#adding-secrets-to-your-project) to upload the `DATABASE_URL`: + +```sh +npx wrangler secret put DATABASE_URL +``` + +When prompted, paste the `DATABASE_URL` value. + +Then execute the following command to deploy your project to Cloudflare Workers: + +```sh +npm run deploy +``` + +The `wrangler` CLI will bundle and upload your application. + +If you’re not already logged in, the `wrangler` CLI will open a browser window prompting you to log in to the [Cloudflare dashboard](https://dash.cloudflare.com/). +:::note +If you belong to multiple accounts, select the account where you want to deploy the project. +::: + +Once the deployment completes, verify the deployment by visiting the live URL provided in the deployment output, such as `https://{PROJECT_NAME}.workers.dev`. If you encounter any issues, ensure the secrets were added correctly and check the deployment logs for errors. + +## Next steps + +Congratulations on building and deploying a simple application with Prisma Postgres and Cloudflare Workers! + +To enhance your application further: + +- Add [caching](https://www.prisma.io/docs/postgres/caching) to your queries. +- Explore the [Prisma Postgres documentation](https://www.prisma.io/docs/postgres/getting-started). + +To see how to build a real-time application with Cloudflare workers and Prisma Postgres, read [this](https://www.prisma.io/docs/guides/prisma-postgres-realtime-on-cloudflare) guide. From 0eba2816b6b962cc23f89d29a0665e0b5cfa54ab Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 12 Feb 2025 17:21:25 +0600 Subject: [PATCH 02/30] chore: change the title --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 1271e3673da99f1..feeef0171ad4893 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -3,7 +3,7 @@ updated: 2025-02-12 difficulty: Beginner content_type: 📝 Tutorial pcx_content_type: tutorial -title: Setup Prisma Postgres database using Workers +title: Set up and use a Prisma Postgres database languages: - TypeScript - SQL From f63d044882651a911cf59c45175094463c6d1991 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:43:07 +0600 Subject: [PATCH 03/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index feeef0171ad4893..28e67bacdd11200 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -84,7 +84,7 @@ Initialize Prisma in your application: npx prisma@latest init --db ``` -If you don't have an account yet, or if you are not logged in, the command will prompt you to log in using one of the available authentication providers. A browser window will open so you can log in or create an account. Return to the CLI after you have completed this step. +If you don't have a [Prisma Data Platform](https://console.prisma.io/) account yet, or if you are not logged in, the command will prompt you to log in using one of the available authentication providers. A browser window will open so you can log in or create an account. Return to the CLI after you have completed this step. Once logged in (or if you were already logged in), the CLI will prompt you to select a project name and a database region. From c8a1fe7e2943483b5350294a622bb062aff70189 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:52:25 +0600 Subject: [PATCH 04/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 28e67bacdd11200..617c89b504779e0 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -90,6 +90,7 @@ Once logged in (or if you were already logged in), the CLI will prompt you to se After the command runs successfully, it will create: +- A project in your [Platform Console](https://console.prisma.io/) containing a Prisma Postgres database instance. - A `prisma` folder containing `schema.prisma`, where you will define your database schema. - An `.env` file in the project root, which will contain the Prisma Postgres database url `DATABASE_URL=`. From 7bdbbd6e2046ebc77612c8e2f102da82470c5d21 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:04:22 +0600 Subject: [PATCH 05/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 617c89b504779e0..daa6ef5272ff549 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -11,7 +11,7 @@ languages: - PostgreSQL --- -[Prisma Postgres](https://www.prisma.io/postgres) is a managed-PostgreSQL database that has built-in connection pooling, caching, real-time subscriptions, and query optimization recommendations. +Prisma Postgres is a managed, serverless PostgreSQL database built on unikernels. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. A free tier is available for initial development and testing. In this tutorial, you will learn how to: From 4353aed89b55b722b0eb401782c1558dca82c284 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:53:47 +0600 Subject: [PATCH 06/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index daa6ef5272ff549..f65a3208017b10a 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -15,7 +15,7 @@ Prisma Postgres is a managed, serverless PostgreSQL database built on unikernels In this tutorial, you will learn how to: -- Set up a Cloudflare workers project with [Prisma ORM](https://www.prisma.io/docs). +- Set up a Cloudflare Workers project with [Prisma ORM](https://www.prisma.io/docs). - Create a Prisma Postgres instance from the CLI. - Query the database from Workers. - Deploy the worker to Cloudflare. From b3a88cc7246380b83538118e258a8d153a936eea Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:53:55 +0600 Subject: [PATCH 07/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index f65a3208017b10a..c336dc6a4cc16a1 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -16,7 +16,8 @@ Prisma Postgres is a managed, serverless PostgreSQL database built on unikernels In this tutorial, you will learn how to: - Set up a Cloudflare Workers project with [Prisma ORM](https://www.prisma.io/docs). -- Create a Prisma Postgres instance from the CLI. +- Create a Prisma Postgres instance from the Prisma CLI. +- Model data and run migrations with Prisma Postgres. - Query the database from Workers. - Deploy the worker to Cloudflare. From e5d0ddb8e2fd965061a01998abbae3afa87d05c7 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:54:03 +0600 Subject: [PATCH 08/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index c336dc6a4cc16a1..a891949186058b6 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -19,7 +19,7 @@ In this tutorial, you will learn how to: - Create a Prisma Postgres instance from the Prisma CLI. - Model data and run migrations with Prisma Postgres. - Query the database from Workers. -- Deploy the worker to Cloudflare. +- Deploy the Worker to Cloudflare. ## Prerequisites From 9c5d4d799346e638c12a5b84f26da9ee5341f228 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:54:16 +0600 Subject: [PATCH 09/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index a891949186058b6..cebe468cffa8a80 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -208,6 +208,7 @@ npm run deploy The `wrangler` CLI will bundle and upload your application. If you’re not already logged in, the `wrangler` CLI will open a browser window prompting you to log in to the [Cloudflare dashboard](https://dash.cloudflare.com/). + :::note If you belong to multiple accounts, select the account where you want to deploy the project. ::: From 208ef7bda940a11e6ca3d1a46a07506d405edbc5 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:54:28 +0600 Subject: [PATCH 10/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index cebe468cffa8a80..30139e6a8a28707 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -11,7 +11,7 @@ languages: - PostgreSQL --- -Prisma Postgres is a managed, serverless PostgreSQL database built on unikernels. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. A free tier is available for initial development and testing. +[Prisma Postgres](https://www.prisma.io/postgres) is a managed, serverless PostgreSQL database built on unikernels. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. A generous free tier is available for initial development, testing and hobby projects. In this tutorial, you will learn how to: From 742072d2adb08145e6eac0e7548e2c6731a79fa4 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:54:38 +0600 Subject: [PATCH 11/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 30139e6a8a28707..1852350456ea57e 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -43,7 +43,7 @@ Then navigate into your project: cd ./prisma-postgres-worker ``` -Your initial `src/index.ts` file contains a simple request handler: +Your initial `src/index.ts` file currently contains a simple request handler: ```ts title="src/index.ts" export default { From 955c130e486f572c50b42d29f4de21a7bee6346e Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:55:01 +0600 Subject: [PATCH 12/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 1852350456ea57e..1767c7c4352da4b 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -167,7 +167,7 @@ export default { datasourceUrl: env.DATABASE_URL, }).$extends(withAccelerate()); - await prisma.user.create({ + const user = await prisma.user.create({ data: { email: `Jon${Math.ceil(Math.random() * 1000)}@gmail.com`, name: "Jon Doe", @@ -176,7 +176,10 @@ export default { const userCount = await prisma.user.count(); - return new Response(`Number of users in the database: ${userCount}`); + return new Response(`\ +Created new user: ${user.name} (${user.email}). +Number of users in the database: ${userCount}. + `); }, } satisfies ExportedHandler; ``` From 4e100e2c161984a94e1ee330945ae2684b5dd9ec Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:55:20 +0600 Subject: [PATCH 13/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 1767c7c4352da4b..f11831b1962861f 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -194,7 +194,7 @@ Visit `https://localhost:8787` to see your app in action. ## 4. Deploy the application to Cloudflare -Use the [`npx wrangler secret put` command](/workers/configuration/secrets/#adding-secrets-to-your-project) to upload the `DATABASE_URL`: +When the application is deployed to Cloudflare, it needs access to the `DATABASE_URL` environment variable that's defined locally in `.dev.vars`. You can use the [`npx wrangler secret put`](/workers/configuration/secrets/#adding-secrets-to-your-project) command to upload the `DATABASE_URL` to the deployment environment: ```sh npx wrangler secret put DATABASE_URL From f110199456c59dcda9e3ee4506d14027c587c2b1 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:55:31 +0600 Subject: [PATCH 14/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index f11831b1962861f..ef6084271dbcadb 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -200,7 +200,7 @@ When the application is deployed to Cloudflare, it needs access to the `DATABASE npx wrangler secret put DATABASE_URL ``` -When prompted, paste the `DATABASE_URL` value. +When prompted, paste the `DATABASE_URL` value (from `.dev.vars`). Then execute the following command to deploy your project to Cloudflare Workers: From 2856c7d472560f449691d4682d91200cc8fb34cd Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:55:51 +0600 Subject: [PATCH 15/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index ef6084271dbcadb..639b16d1278d92e 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -68,7 +68,7 @@ npm install prisma --save-dev Install the [Prisma Accelerate client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) as that's required for Prisma Postgres: ```sh -npm i @prisma/extension-accelerate +npm install @prisma/extension-accelerate ``` Install the [`dotenv-cli` package](https://www.npmjs.com/package/dotenv-cli) to load environment variables from `.dev.vars`: From 6c66bbb6e5fea87d647156ef550097a28585ecfc Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:56:37 +0600 Subject: [PATCH 16/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 639b16d1278d92e..4ecd7b9727b2c02 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -89,7 +89,7 @@ If you don't have a [Prisma Data Platform](https://console.prisma.io/) account y Once logged in (or if you were already logged in), the CLI will prompt you to select a project name and a database region. -After the command runs successfully, it will create: +Once the command has terminated, it has created: - A project in your [Platform Console](https://console.prisma.io/) containing a Prisma Postgres database instance. - A `prisma` folder containing `schema.prisma`, where you will define your database schema. From cd2ec5c05cfbe5a20d1cfead63e519a186860d3d Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:56:58 +0600 Subject: [PATCH 17/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 4ecd7b9727b2c02..a2324c66681e2c5 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -74,7 +74,7 @@ npm install @prisma/extension-accelerate Install the [`dotenv-cli` package](https://www.npmjs.com/package/dotenv-cli) to load environment variables from `.dev.vars`: ```sh -npm i -D dotenv-cli +npm install dotenv-cli --save-dev ``` ### 2.2. Create a Prisma Postgres database and initialize Prisma From 7730c59b800dac7f4e43e0d3fa6c41f69174cb48 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:57:27 +0600 Subject: [PATCH 18/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index a2324c66681e2c5..7708ac1370fcd89 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -95,7 +95,7 @@ Once the command has terminated, it has created: - A `prisma` folder containing `schema.prisma`, where you will define your database schema. - An `.env` file in the project root, which will contain the Prisma Postgres database url `DATABASE_URL=`. -You will use a `.dev.vars` file instead of the created `.env` file. +Note that Cloudflare Workers don't support `.env` files. You will use a file called `.dev.vars` instead of the `.env` file that was just created. ### 2.3. Prepare environment variables From b7e630524e9b554123f4abc21def64f9e4361846 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:58:08 +0600 Subject: [PATCH 19/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 7708ac1370fcd89..bba6908ef788a88 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -151,7 +151,7 @@ After these steps are complete, Prisma ORM is fully set up and connected to your ## 3. Develop the application -Modify the `src/index.ts` file with the following code: +Modify the `src/index.ts` file and replace its contents with the following code: ```ts title="src/index.ts" import { PrismaClient } from "@prisma/client/edge"; From 55822d1ff619e8096f39bd338b4801766bf5e13f Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:59:03 +0600 Subject: [PATCH 20/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index bba6908ef788a88..96c2c34d82aab88 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -99,14 +99,12 @@ Note that Cloudflare Workers don't support `.env` files. You will use a file cal ### 2.3. Prepare environment variables -Create a `.dev.vars` file in the root of your application and copy the `DATABASE_URL` from the `.env` file. You can also do this via the CLI: +Rename the `.env` file in the root of your application to `.dev.vars` file: ```sh -cp .env .dev.vars +mv .env .dev.vars ``` -Then, you can remove the `.env` file. - ### 2.4. Apply database schema changes Open the `schema.prisma` file in the `prisma` folder and add the following `User` model to your database: From e5abe97a76912251c8475a12f217856939d80f43 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:59:13 +0600 Subject: [PATCH 21/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Nikolas --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 96c2c34d82aab88..1aae0dd4d70423a 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -188,7 +188,7 @@ Run the development server: npm run dev ``` -Visit `https://localhost:8787` to see your app in action. +Visit [`https://localhost:8787`](https://localhost:8787) to see your app in action. ## 4. Deploy the application to Cloudflare From d0fcb325fc06e3d3d0b927147e99fc0f51f66f55 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 17:11:27 +0600 Subject: [PATCH 22/30] chore: add secrets adding output --- .../using-prisma-postgres-with-workers/index.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 1aae0dd4d70423a..8136d257c959ad3 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -99,7 +99,7 @@ Note that Cloudflare Workers don't support `.env` files. You will use a file cal ### 2.3. Prepare environment variables -Rename the `.env` file in the root of your application to `.dev.vars` file: +Rename the `.env` file in the root of your application to `.dev.vars` file: ```sh mv .env .dev.vars @@ -198,7 +198,11 @@ When the application is deployed to Cloudflare, it needs access to the `DATABASE npx wrangler secret put DATABASE_URL ``` -When prompted, paste the `DATABASE_URL` value (from `.dev.vars`). +When prompted, paste the `DATABASE_URL` value (from `.dev.vars`). If you're logged in via the Wrangler CLI, you'll see a prompt asking if you'd like to create a new Worker. Confirm by choosing "yes": + +```sh +✔ There doesn't seem to be a Worker called "prisma-postgres-worker". Do you want to create a new Worker with that name and add secrets to it? … yes +``` Then execute the following command to deploy your project to Cloudflare Workers: From f8b4e4f3ef06c2aad8de5ec8b3da5eac7bcbf948 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 13 Feb 2025 19:51:49 +0600 Subject: [PATCH 23/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 8136d257c959ad3..33dc3551b788e0d 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -229,4 +229,4 @@ To enhance your application further: - Add [caching](https://www.prisma.io/docs/postgres/caching) to your queries. - Explore the [Prisma Postgres documentation](https://www.prisma.io/docs/postgres/getting-started). -To see how to build a real-time application with Cloudflare workers and Prisma Postgres, read [this](https://www.prisma.io/docs/guides/prisma-postgres-realtime-on-cloudflare) guide. +To see how to build a real-time application with Cloudflare Workers and Prisma Postgres, read [this](https://www.prisma.io/docs/guides/prisma-postgres-realtime-on-cloudflare) guide. From 6e020d4bd003f3faa64a392f54e7f568d31bab36 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:51:32 +0600 Subject: [PATCH 24/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 33dc3551b788e0d..4e8988d0a987266 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -11,7 +11,7 @@ languages: - PostgreSQL --- -[Prisma Postgres](https://www.prisma.io/postgres) is a managed, serverless PostgreSQL database built on unikernels. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. A generous free tier is available for initial development, testing and hobby projects. +[Prisma Postgres](https://www.prisma.io/postgres) is a managed, serverless PostgreSQL database. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. In this tutorial, you will learn how to: From 3f7dc93e86a0add924ed8b16bba090275735b394 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:51:44 +0600 Subject: [PATCH 25/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com> --- .../using-prisma-postgres-with-workers/index.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 4e8988d0a987266..313ca982c41fcf0 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -161,6 +161,14 @@ export interface Env { export default { async fetch(request, env, ctx): Promise { + const path = (new URL(request.url)).pathname; + if(path === "/favicon.ico") return new Response('Resource not found', { + status: 404, + headers: { + 'Content-Type': 'text/plain' + } + }); + const prisma = new PrismaClient({ datasourceUrl: env.DATABASE_URL, }).$extends(withAccelerate()); From edca9330b56138b2e8a8d073430e6e2488315583 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:51:57 +0600 Subject: [PATCH 26/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Mike Nomitch --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 313ca982c41fcf0..6d3172be06f5a0c 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -65,7 +65,7 @@ Install Prisma CLI as a dev dependency: npm install prisma --save-dev ``` -Install the [Prisma Accelerate client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) as that's required for Prisma Postgres: +Install the [Prisma Accelerate client extension](https://www.npmjs.com/package/@prisma/extension-accelerate) as it is required for Prisma Postgres: ```sh npm install @prisma/extension-accelerate From 25e15ebdb6b0d66c21b84b38bf5c1c7699bfd1e5 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:52:09 +0600 Subject: [PATCH 27/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx Co-authored-by: Mike Nomitch --- .../tutorials/using-prisma-postgres-with-workers/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 6d3172be06f5a0c..6a8b3e4934ff096 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -55,7 +55,7 @@ export default { ## 2. Setup Prisma in your project -In this step, we set up Prisma ORM with a Prisma Postgres database using the CLI. Then we'll create and execute helper scripts to create tables in our database and generate a Prisma client to query it. +In this step, you will set up Prisma ORM with a Prisma Postgres database using the CLI. Then you will create and execute helper scripts to create tables in the database and generate a Prisma client to query it. ### 2.1. Install required dependencies From 2cdddab56ccfbc013f3ff099191a83a4818be4f1 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Fri, 14 Feb 2025 05:01:06 +0600 Subject: [PATCH 28/30] chore: add more clarity --- .../index.mdx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index 6a8b3e4934ff096..ac44bd175d75190 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -11,7 +11,7 @@ languages: - PostgreSQL --- -[Prisma Postgres](https://www.prisma.io/postgres) is a managed, serverless PostgreSQL database. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. +[Prisma Postgres](https://www.prisma.io/postgres) is a managed, serverless PostgreSQL database. It supports features like connection pooling, caching, real-time subscriptions, and query optimization recommendations. In this tutorial, you will learn how to: @@ -161,14 +161,15 @@ export interface Env { export default { async fetch(request, env, ctx): Promise { - const path = (new URL(request.url)).pathname; - if(path === "/favicon.ico") return new Response('Resource not found', { - status: 404, - headers: { - 'Content-Type': 'text/plain' - } - }); - + const path = new URL(request.url).pathname; + if (path === "/favicon.ico") + return new Response("Resource not found", { + status: 404, + headers: { + "Content-Type": "text/plain", + }, + }); + const prisma = new PrismaClient({ datasourceUrl: env.DATABASE_URL, }).$extends(withAccelerate()); @@ -196,7 +197,13 @@ Run the development server: npm run dev ``` -Visit [`https://localhost:8787`](https://localhost:8787) to see your app in action. +Visit [`https://localhost:8787`](https://localhost:8787) to see your app display the following output: + +```sh +Number of users in the database: 1 +``` + +Every time you refresh the page, a new user is created. The number displayed will increment by `1` with each refresh as it returns the total number of users in your database. ## 4. Deploy the application to Cloudflare From 541a2062169958c70b96104e743e4b798a2af1c5 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Tue, 18 Feb 2025 17:42:51 +0000 Subject: [PATCH 29/30] Apply suggestions from code review --- .../using-prisma-postgres-with-workers/index.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx index ac44bd175d75190..f5ed30d211864c0 100644 --- a/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx +++ b/src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx @@ -85,17 +85,17 @@ Initialize Prisma in your application: npx prisma@latest init --db ``` -If you don't have a [Prisma Data Platform](https://console.prisma.io/) account yet, or if you are not logged in, the command will prompt you to log in using one of the available authentication providers. A browser window will open so you can log in or create an account. Return to the CLI after you have completed this step. +If you do not have a [Prisma Data Platform](https://console.prisma.io/) account yet, or if you are not logged in, the command will prompt you to log in using one of the available authentication providers. A browser window will open so you can log in or create an account. Return to the CLI after you have completed this step. Once logged in (or if you were already logged in), the CLI will prompt you to select a project name and a database region. -Once the command has terminated, it has created: +Once the command has terminated, it will have created: - A project in your [Platform Console](https://console.prisma.io/) containing a Prisma Postgres database instance. - A `prisma` folder containing `schema.prisma`, where you will define your database schema. - An `.env` file in the project root, which will contain the Prisma Postgres database url `DATABASE_URL=`. -Note that Cloudflare Workers don't support `.env` files. You will use a file called `.dev.vars` instead of the `.env` file that was just created. +Note that Cloudflare Workers do not support `.env` files. You will use a file called `.dev.vars` instead of the `.env` file that was just created. ### 2.3. Prepare environment variables @@ -143,7 +143,7 @@ Run the migration script to apply changes to the database: npm run migrate ``` -When prompted, provide a name for the migration (e.g., `init`). +When prompted, provide a name for the migration (for example, `init`). After these steps are complete, Prisma ORM is fully set up and connected to your Prisma Postgres database. @@ -207,13 +207,13 @@ Every time you refresh the page, a new user is created. The number displayed wil ## 4. Deploy the application to Cloudflare -When the application is deployed to Cloudflare, it needs access to the `DATABASE_URL` environment variable that's defined locally in `.dev.vars`. You can use the [`npx wrangler secret put`](/workers/configuration/secrets/#adding-secrets-to-your-project) command to upload the `DATABASE_URL` to the deployment environment: +When the application is deployed to Cloudflare, it needs access to the `DATABASE_URL` environment variable that is defined locally in `.dev.vars`. You can use the [`npx wrangler secret put`](/workers/configuration/secrets/#adding-secrets-to-your-project) command to upload the `DATABASE_URL` to the deployment environment: ```sh npx wrangler secret put DATABASE_URL ``` -When prompted, paste the `DATABASE_URL` value (from `.dev.vars`). If you're logged in via the Wrangler CLI, you'll see a prompt asking if you'd like to create a new Worker. Confirm by choosing "yes": +When prompted, paste the `DATABASE_URL` value (from `.dev.vars`). If you are logged in via the Wrangler CLI, you will see a prompt asking if you'd like to create a new Worker. Confirm by choosing "yes": ```sh ✔ There doesn't seem to be a Worker called "prisma-postgres-worker". Do you want to create a new Worker with that name and add secrets to it? … yes @@ -227,7 +227,7 @@ npm run deploy The `wrangler` CLI will bundle and upload your application. -If you’re not already logged in, the `wrangler` CLI will open a browser window prompting you to log in to the [Cloudflare dashboard](https://dash.cloudflare.com/). +If you are not already logged in, the `wrangler` CLI will open a browser window prompting you to log in to the [Cloudflare dashboard](https://dash.cloudflare.com/). :::note If you belong to multiple accounts, select the account where you want to deploy the project. From 3f52c2fbae9633a721a72b13729869ed653cb159 Mon Sep 17 00:00:00 2001 From: Jun Lee Date: Tue, 18 Feb 2025 17:48:22 +0000 Subject: [PATCH 30/30] Update src/content/docs/workers/tutorials/using-prisma-postgres-with-workers/index.mdx