Skip to content

Commit 744c7ae

Browse files
nurul3101aidankmcalister
authored andcommitted
(feat) Removes Accelerate specific instructions for Prisma Postgres (#7268)
* (feat) Removes Accelerate specific instructions for Prisma Postgres * feat: update Deno integration guide to include additional development dependencies
1 parent bcb7848 commit 744c7ae

26 files changed

+250
-638
lines changed

content/800-guides/010-data-migration.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,19 @@ export default defineConfig({
8282

8383
:::note
8484

85-
You'll need to install the `dotenv` package to load environment variables. If you haven't already, install it using your package manager:
85+
You'll need to install the required packages. If you haven't already, install them using your package manager:
8686

8787
```bash
88-
npm install dotenv
88+
npm install prisma @types/pg --save-dev
89+
npm install @prisma/client @prisma/adapter-pg pg dotenv
8990
```
9091

92+
:::info
93+
94+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
95+
96+
:::
97+
9198
:::
9299

93100
### 1.3. Create a development branch

content/800-guides/050-migrate-from-mongoose.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ This guide uses Prisma ORM v6.19 to ensure full compatibility with MongoDB.
2222

2323
You can learn how Prisma ORM compares to Mongoose on the [Prisma ORM vs Mongoose](/orm/more/comparisons/prisma-and-mongoose) page.
2424

25+
:::warning
26+
27+
This guide currently assumes you are using **Prisma ORM v6**. Support for Prisma ORM v7 with MongoDB is in progress.
28+
29+
:::
30+
2531
## Prerequisites
2632

2733
Before starting this guide, make sure you have:

content/800-guides/060-migrate-from-drizzle.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ Prisma ORM lends itself really well for **incremental adoption**. This means, yo
5050
The first step to adopt Prisma ORM is to [install the Prisma CLI](/orm/tools/prisma-cli#installation) in your project:
5151

5252
```terminal copy
53-
npm install prisma --save-dev && npm install @prisma/client
53+
npm install prisma @types/pg --save-dev
54+
npm install @prisma/client @prisma/adapter-pg pg
5455
```
5556

57+
:::info
58+
59+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
60+
61+
:::
62+
5663
## Step 2. Introspect your database
5764

5865
### 2.1. Set up Prisma ORM
@@ -252,15 +259,9 @@ model Todo {
252259
}
253260
```
254261

255-
## Step 3. Install and generate Prisma Client
256-
257-
As a next step, you can install Prisma Client in your project so that you can start replacing the database queries in your project that are currently made with Drizzle:
258-
259-
```terminal
260-
npm install @prisma/client
261-
```
262+
## Step 3. Generate Prisma Client
262263

263-
After installing, you need to run `generate` in order to have your schema reflected in TypeScript types and autocomplete.
264+
Now that you have installed Prisma Client in Step 1, you need to run `generate` in order to have your schema reflected in TypeScript types and autocomplete.
264265

265266
```terminal
266267
npx prisma generate

content/800-guides/080-turborepo.mdx

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -93,60 +93,34 @@ Next, install the required dependencies to use Prisma ORM. Use your preferred pa
9393
<TabItem value="npm">
9494

9595
```terminal
96-
npm install prisma --save-dev
97-
npm install @prisma/client dotenv
96+
npm install prisma @types/pg --save-dev
97+
npm install @prisma/client @prisma/adapter-pg dotenv pg
9898
```
9999

100100
</TabItem>
101101

102102
<TabItem value="yarn">
103103

104104
```terminal
105-
yarn add prisma --dev
106-
yarn add @prisma/client dotenv
105+
yarn add prisma @types/pg --dev
106+
yarn add @prisma/client @prisma/adapter-pg dotenv pg
107107
```
108108

109109
</TabItem>
110110

111111
<TabItem value="pnpm">
112112

113113
```terminal
114-
pnpm add prisma --save-dev
115-
pnpm add @prisma/client dotenv
114+
pnpm add prisma @types/pg --save-dev
115+
pnpm add @prisma/client @prisma/adapter-pg dotenv pg
116116
```
117117

118118
</TabItem>
119119
</TabbedContent>
120120

121-
:::note
122-
123-
If using [Prisma Postgres](https://prisma.io/postgres), install the `@prisma/extension-accelerate` package:
124-
125-
<TabbedContent code groupId="packageManager">
126-
<TabItem value="npm">
127-
128-
```terminal
129-
npm install @prisma/extension-accelerate
130-
```
131-
132-
</TabItem>
133-
134-
<TabItem value="yarn">
135-
136-
```terminal
137-
yarn add @prisma/extension-accelerate
138-
```
139-
140-
</TabItem>
141-
142-
<TabItem value="pnpm">
143-
144-
```terminal
145-
pnpm add @prisma/extension-accelerate
146-
```
121+
:::info
147122

148-
</TabItem>
149-
</TabbedContent>
123+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
150124

151125
:::
152126

@@ -389,27 +363,6 @@ Next, export the generated types and an instance of `PrismaClient` so it can use
389363

390364
In the `packages/database` directory, create a `src` folder and add a `client.ts` file. This file will define an instance of `PrismaClient`:
391365

392-
<TabbedContent code>
393-
<TabItem value="Prisma Postgres (recommended)">
394-
395-
```ts file=packages/database/src/client.ts
396-
import { PrismaClient } from "../generated/prisma";
397-
import { withAccelerate } from "@prisma/extension-accelerate";
398-
399-
const globalForPrisma = global as unknown as { prisma: PrismaClient };
400-
401-
export const prisma =
402-
globalForPrisma.prisma || new PrismaClient({
403-
accelerateUrl: process.env.DATABASE_URL,
404-
}).$extends(withAccelerate());
405-
406-
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
407-
```
408-
409-
</TabItem>
410-
411-
<TabItem value="Other databases">
412-
413366
```ts file=packages/database/src/client.ts
414367
import { PrismaClient } from "../generated/prisma";
415368
import { PrismaPg } from '@prisma/adapter-pg';
@@ -428,9 +381,6 @@ export const prisma =
428381
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
429382
```
430383

431-
</TabItem>
432-
</TabbedContent>
433-
434384
Then create an `index.ts` file in the `src` folder to re-export the generated prisma types and the `PrismaClient` instance:
435385

436386
```ts file=packages/database/src/index.ts

content/800-guides/090-nextjs.mdx

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,16 @@ cd nextjs-prisma
6666

6767
To get started with Prisma, you'll need to install a few dependencies:
6868

69-
<TabbedContent code>
70-
<TabItem value="Prisma Postgres (recommended)">
7169
```terminal
72-
npm install prisma tsx --save-dev
73-
npm install @prisma/extension-accelerate @prisma/client dotenv
70+
npm install prisma tsx @types/pg --save-dev
71+
npm install @prisma/client @prisma/adapter-pg dotenv pg
7472
```
75-
</TabItem>
76-
<TabItem value="Other databases">
77-
```terminal
78-
npm install prisma tsx --save-dev
79-
npm install @prisma/client dotenv
80-
```
81-
</TabItem>
82-
</TabbedContent>
73+
74+
:::info
75+
76+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
77+
78+
:::
8379

8480
Once installed, initialize Prisma in your project:
8581

@@ -287,32 +283,9 @@ mkdir -p lib && touch lib/prisma.ts
287283

288284
Now, add the following code to your `lib/prisma.ts` file:
289285

290-
<TabbedContent code>
291-
<TabItem value="Prisma Postgres (recommended)">
292286
```typescript file=lib/prisma.ts showLineNumbers
293287
//add-start
294288
import { PrismaClient } from '../app/generated/prisma'
295-
import { withAccelerate } from '@prisma/extension-accelerate'
296-
297-
const globalForPrisma = global as unknown as {
298-
prisma: PrismaClient
299-
}
300-
301-
const prisma = globalForPrisma.prisma || new PrismaClient({
302-
accelerateUrl: process.env.DATABASE_URL,
303-
}).$extends(withAccelerate())
304-
305-
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
306-
307-
export default prisma
308-
//add-end
309-
```
310-
</TabItem>
311-
312-
<TabItem value="Other databases">
313-
```typescript file=lib/prisma.ts showLineNumbers
314-
//add-start
315-
import { PrismaClient } from '../src/app/generated/prisma'
316289
import { PrismaPg } from '@prisma/adapter-pg'
317290

318291
const globalForPrisma = global as unknown as {
@@ -332,8 +305,6 @@ if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
332305
export default prisma
333306
//add-end
334307
```
335-
</TabItem>
336-
</TabbedContent>
337308

338309
This file creates a Prisma Client and attaches it to the global object so that only one instance of the client is created in your application. This helps resolve issues with hot reloading that can occur when using Prisma ORM with Next.js in development mode.
339310

@@ -707,9 +678,10 @@ Before you deploy, you also need to tell Vercel to make sure that the Prisma Cli
707678
"seed": "tsx prisma/seed.ts"
708679
},
709680
"dependencies": {
681+
"@prisma/adapter-pg": "^6.2.1",
710682
"@prisma/client": "^6.2.1",
711-
"@prisma/extension-accelerate": "^1.2.1",
712683
"next": "15.1.4",
684+
"pg": "^8.13.1",
713685
"react": "^19.0.0",
714686
"react-dom": "^19.0.0"
715687
},

content/800-guides/130-docker.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ This will generate a `package.json` file:
7878
Next, install the Prisma CLI as a development dependency and Express.js for the server:
7979

8080
```terminal
81-
npm install prisma --save-dev && npm install @prisma/client
82-
npm install express
81+
npm install prisma @types/pg --save-dev
82+
npm install @prisma/client @prisma/adapter-pg pg dotenv express
8383
```
8484

85+
:::info
86+
87+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
88+
89+
:::
90+
8591
### 1.3. Set up Prisma ORM
8692

8793
Now, initialize Prisma to generate the necessary files:

content/800-guides/140-use-prisma-in-pnpm-workspaces.mdx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,13 @@ pnpm install
9393
Then, add additional dependencies:
9494

9595
```terminal
96-
pnpm add typescript tsx @types/node -D
97-
```
98-
99-
Then install the Prisma Client extension required to use Prisma Postgres:
100-
101-
```terminal
102-
pnpm add @prisma/extension-accelerate
96+
pnpm add typescript tsx @types/node @types/pg -D
97+
pnpm add @prisma/adapter-pg pg
10398
```
10499

105100
:::info
106101

107-
This guide uses [Prisma Postgres](/postgres/getting-started). If you plan to use a different database, you can omit the [@prisma/extension-accelerate package](https://www.npmjs.com/package/@prisma/extension-accelerate/).
102+
If you are using a different database provider (MySQL, SQL Server, SQLite), install the corresponding driver adapter package instead of `@prisma/adapter-pg`. For more information, see [Database drivers](/orm/overview/databases/database-drivers).
108103

109104
:::
110105

@@ -215,40 +210,34 @@ pnpm run db:migrate
215210

216211
When prompted by the CLI, enter a descriptive name for your migration.
217212

218-
Once the migration is successful, create a `client.ts` file to initialize Prisma Client with the Accelerate extension:
213+
Once the migration is successful, create a `client.ts` file to initialize Prisma Client with a driver adapter:
219214

220215
```ts file=database/client.ts
221216
// add-start
222217
import { PrismaClient } from "./generated/client";
223-
import { withAccelerate } from "@prisma/extension-accelerate";
218+
import { PrismaPg } from "@prisma/adapter-pg";
224219
225-
// Instantiate the extended Prisma client to infer its type
226-
const extendedPrisma = new PrismaClient({
227-
accelerateUrl: process.env.DATABASE_URL,
228-
}).$extends(withAccelerate());
229-
type ExtendedPrismaClient = typeof extendedPrisma;
220+
const adapter = new PrismaPg({
221+
connectionString: process.env.DATABASE_URL,
222+
});
230223
231224
// Use globalThis for broader environment compatibility
232225
const globalForPrisma = globalThis as typeof globalThis & {
233-
prisma?: ExtendedPrismaClient;
226+
prisma?: PrismaClient;
234227
};
235228
236229
// Named export with global memoization
237-
export const prisma: ExtendedPrismaClient =
238-
globalForPrisma.prisma ?? extendedPrisma;
230+
export const prisma: PrismaClient =
231+
globalForPrisma.prisma ?? new PrismaClient({
232+
adapter,
233+
});
239234
240235
if (process.env.NODE_ENV !== "production") {
241236
globalForPrisma.prisma = prisma;
242237
}
243238
// add-end
244239
```
245240

246-
:::info
247-
248-
If you're not using [Prisma Postgres](/postgres/getting-started) for your database, exclude the `import { withAccelerate }` line and `.$extends(withAccelerate())` from the line following it.
249-
250-
:::
251-
252241
Then, create an `index.ts` file to re-export the instance of Prisma Client and all generated types:
253242

254243
```ts file=database/index.ts

0 commit comments

Comments
 (0)