Skip to content

Commit 03ea8bf

Browse files
add migrate guide for accelerate users (#7357)
1 parent e4bcf8f commit 03ea8bf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/400-upgrading-to-prisma-7.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,34 @@ const adapter = new PrismaBetterSqlite3({
212212
export const prisma = new PrismaClient({ adapter })
213213
```
214214

215+
### Prisma Accelerate users upgrading from v6
216+
If you used Prisma Accelerate (including Prisma Postgres' `prisma+postgres://` URLs) in v6, keep using the Accelerate URL with the Accelerate extension. Do **not** pass the Accelerate URL to a driver adapter—`PrismaPg` expects a direct database connection string and will fail with `prisma://` or `prisma+postgres://`.
217+
218+
1. Keep your Accelerate URL in `.env` (for example `DATABASE_URL="prisma://..."` or `prisma+postgres://...`).
219+
2. You can point `prisma.config.ts` directly to that same Accelerate URL for CLI operations:
220+
```ts file=prisma.config.ts
221+
import 'dotenv/config'
222+
import { defineConfig, env } from 'prisma/config'
223+
224+
export default defineConfig({
225+
schema: 'prisma/schema.prisma',
226+
datasource: {
227+
url: env('DATABASE_URL'),
228+
},
229+
})
230+
```
231+
- If you prefer a separate direct URL for migrations, you can still use `DIRECT_DATABASE_URL` as above—but it's optional for Accelerate users.
232+
3. Instantiate Prisma Client with the Accelerate URL and extension (no adapter):
233+
```ts
234+
import { PrismaClient } from './generated/prisma/client'
235+
import { withAccelerate } from '@prisma/extension-accelerate'
236+
237+
export const prisma = new PrismaClient({
238+
accelerateUrl: process.env.DATABASE_URL,
239+
}).$extends(withAccelerate())
240+
```
241+
If you later switch away from Accelerate to direct TCP, provide the direct URL to the appropriate driver adapter (for example `PrismaPg`) instead of `accelerateUrl`.
242+
215243
### Explicit loading of environment variables
216244
In Prisma ORM 7.0.0, environment variables are not loaded by default. Instead developers need to
217245
explicitly load the variables when calling the `prisma` CLI. Libraries like [`dotenv`](https://github.com/motdotla/dotenv) can be used to manage loading environment variables by reading the appropriate `.env` file.

0 commit comments

Comments
 (0)