Skip to content

Commit add894e

Browse files
Update all examples to Prisma 7 (#8383)
* Update all accelerate example (#8373) * Update misc examples (#8372) * Update misc examples with prisma.config.ts and adapter (#8362) * Update HTTP web server examples (#8354) * update all nextjs examples in `generator-prisma-client/` (#8342) * Update fullstack examples with prisma config and pg adapter (#8344) Co-authored-by: Nurul Sundarani <sundarani@prisma.io> * Update Nuxt & React Router examples (#8368) * Update optimize examples (#8375) * Update Bun & Deno examples (#8343) * Update GraphQL examples with prisma.config.ts and pg adapter (#8345) * update cockroachdb, postgresql-supabase, prisma-postgres examples (#8374) * remove engine classic and url from schema.prisma * update deployment * update readme * delete all lock files and update prisma version to 7.0.0 * update remaining examples * update d1 example * fix * update turso example * fix * update nuxt example * fix nextjs example * update all deps to 7.0.0 * fix --------- Co-authored-by: Nurul Sundarani <sundarani@prisma.io>
1 parent b54d36d commit add894e

File tree

456 files changed

+2724
-58430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

456 files changed

+2724
-58430
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ tmp-resolvers
1515
package-lock.json
1616
flow-typed
1717
yarn.lock
18+
bun.lock
19+
pnpm-lock.yaml
1820
orm/**/migrations/
1921
misc/**/migrations/
2022
databases/**/migrations/

accelerate/accelerate-hacker-news/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@ Create a `.env` in the root of the project directory:
3333
cp .env.example .env
3434
```
3535

36-
Now, open the `.env` file and set the `DATABASE_URL` and `DIRECT_URL` environment variables with the values of your connection string and your Accelerate connection string:
36+
Now, open the `.env` file and set the `DATABASE_URL` environment variable with the value of your Accelerate connection string:
3737

3838
```bash
3939
# .env
4040

4141
# Accelerate connection string (used for queries by Prisma Client)
4242
DATABASE_URL="__YOUR_ACCELERATE_CONNECTION_STRING__"
43-
44-
# Database connection string (used for migrations by Prisma Migrate)
45-
DIRECT_URL="__YOUR_DATABASE_CONNECTION_STRING__"
4643
```
4744

48-
Note that `__YOUR_DATABASE_CONNECTION_STRING__` and `__YOUR_ACCELERATE_CONNECTION_STRING__` are placeholder values that you need to replace with the values of your database and Accelerate connection strings. Notice that the Accelerate connection string has the following structure: `prisma://accelerate.prisma-data.net/?api_key=__YOUR_ACCELERATE_API_KEY__`.
45+
Note that `__YOUR_ACCELERATE_CONNECTION_STRING__` is a placeholder value that you need to replace with the value of your Accelerate connection string. Notice that the Accelerate connection string has the following structure: `prisma://accelerate.prisma-data.net/?api_key=__YOUR_ACCELERATE_API_KEY__`.
4946

5047
### 3. Run a migration to create the `Post` table
5148

@@ -55,12 +52,12 @@ The Prisma schema file contains a single `Post` model. You can map this model to
5552
npx prisma migrate dev --name init
5653
```
5754

58-
### 4. Generate Prisma Client for Accelerate
55+
### 4. Generate Prisma Client
5956

60-
When using Accelerate, Prisma Client doesn't need a query engine. That's why you should generate it as follows:
57+
Generate Prisma Client with the following command:
6158

6259
```
63-
npx prisma generate --no-engine
60+
npx prisma generate
6461
```
6562

6663
### 5. Start the app

accelerate/accelerate-hacker-news/lib/db.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { PrismaClient } from '@prisma/client'
1+
import "dotenv/config"
2+
import { PrismaClient } from '../prisma/generated/client'
23
import { withAccelerate } from '@prisma/extension-accelerate'
34

45
const prismaClientSingleton = () => {
5-
return new PrismaClient().$extends(withAccelerate())
6+
return new PrismaClient({
7+
accelerateUrl: process.env.DATABASE_URL,
8+
}).$extends(withAccelerate())
69
}
710

811
declare const globalThis: {

accelerate/accelerate-hacker-news/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@prisma/client": "6.9.0",
13-
"@prisma/extension-accelerate": "2.0.2",
12+
"@prisma/client": "7.0.0",
13+
"@prisma/extension-accelerate": "^2.0.2",
1414
"next": "15.3.5",
1515
"react": "19.1.0",
1616
"react-dom": "19.1.0"
1717
},
1818
"devDependencies": {
19-
"prisma": "6.9.0",
2019
"@faker-js/faker": "9.9.0",
2120
"@types/node": "22.19.0",
2221
"@types/react": "19.1.8",
2322
"@types/react-dom": "19.1.6",
2423
"eslint": "8.57.1",
2524
"eslint-config-next": "15.3.5",
2625
"postcss": "8.5.6",
26+
"prisma": "7.0.0",
2727
"tailwindcss": "3.4.17",
2828
"tsx": "4.20.6",
2929
"typescript": "5.8.2"
3030
},
3131
"prisma": {
3232
"seed": "tsx ./prisma/seed.ts"
3333
}
34-
}
34+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "dotenv/config";
2+
import { defineConfig, env } from "prisma/config";
3+
4+
export default defineConfig({
5+
schema: "prisma/schema.prisma",
6+
migrations: {
7+
path: "prisma/migrations",
8+
seed: "tsx ./prisma/seed.ts",
9+
},
10+
datasource: {
11+
url: env("DATABASE_URL"),
12+
},
13+
});
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
generator client {
2-
provider = "prisma-client-js"
2+
provider = "prisma-client"
3+
output = "./generated"
34
}
45

56
datasource db {
67
provider = "postgresql"
7-
url = env("DATABASE_URL")
8-
directUrl = env("DIRECT_URL")
98
}
109

1110
model Post {
12-
id Int @id @default(autoincrement())
11+
id Int @id @default(autoincrement())
1312
title String
1413
url String
1514
content String
1615
vote Int
17-
createdAt DateTime @default(now())
18-
updatedAt DateTime @updatedAt
16+
createdAt DateTime @default(now())
17+
updatedAt DateTime @updatedAt
1918
}

accelerate/accelerate-hacker-news/prisma/seed.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { PrismaClient } from '@prisma/client'
1+
import "dotenv/config"
2+
import { PrismaClient } from './generated/client'
23
import { faker } from '@faker-js/faker'
4+
import { withAccelerate } from '@prisma/extension-accelerate'
35

4-
const prisma = new PrismaClient()
6+
const prisma = new PrismaClient({
7+
accelerateUrl: process.env.DATABASE_URL,
8+
}).$extends(withAccelerate())
59

610
const main = async () => {
711
await prisma.post.deleteMany()

accelerate/accelerate-hacker-news/tsconfig.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"compilerOptions": {
3-
"lib": ["dom", "dom.iterable", "esnext"],
3+
"lib": [
4+
"dom",
5+
"dom.iterable",
6+
"esnext"
7+
],
48
"allowJs": true,
59
"skipLibCheck": true,
610
"strict": true,
@@ -18,9 +22,19 @@
1822
}
1923
],
2024
"paths": {
21-
"@/*": ["./*"]
22-
}
25+
"@/*": [
26+
"./*"
27+
]
28+
},
29+
"target": "ES2017"
2330
},
24-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25-
"exclude": ["node_modules"]
31+
"include": [
32+
"next-env.d.ts",
33+
"**/*.ts",
34+
"**/*.tsx",
35+
".next/types/**/*.ts"
36+
],
37+
"exclude": [
38+
"node_modules"
39+
]
2640
}

accelerate/astro-starter/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@ Copy the `.env.example` env file in the root of the project directory:
2929
cp .env.example .env
3030
```
3131

32-
Now, open the `.env` file and set the `DIRECT_URL` and `DATABASE_URL` environment variables with the values of your connection string and your Accelerate connection string respectively:
32+
Now, open the `.env` file and set the `DATABASE_URL` environment variable with the value of your Accelerate connection string:
3333

3434
```bash
3535
# .env
3636

3737
# Accelerate connection string (used for queries by Prisma Client)
3838
DATABASE_URL="__YOUR_ACCELERATE_CONNECTION_STRING__"
3939

40-
# Database connection string (used for migrations by Prisma Migrate)
41-
DIRECT_URL="__YOUR_DATABASE_CONNECTION_STRING__"
42-
4340
```
4441

45-
Note that `__YOUR_DATABASE_CONNECTION_STRING__` and `__YOUR_ACCELERATE_CONNECTION_STRING__` are placeholder values that you need to replace with the values of your database and Accelerate connection strings. Notice that the Accelerate connection string has the following structure: `prisma://accelerate.prisma-data.net/?api_key=__YOUR_ACCELERATE_API_KEY__`.
42+
Note that `__YOUR_ACCELERATE_CONNECTION_STRING__` is a placeholder value that you need to replace with the value of your Accelerate connection string. Notice that the Accelerate connection string has the following structure: `prisma://accelerate.prisma-data.net/?api_key=__YOUR_ACCELERATE_API_KEY__`.
4643

4744
### 3. Run a migration to create the `Quote` table and seed the database
4845

@@ -58,12 +55,12 @@ You now have an empty `Quote` table in your database. Next, run the [seed script
5855
npx prisma db seed
5956
```
6057

61-
### 4. Generate Prisma Client for Accelerate
58+
### 4. Generate Prisma Client
6259

63-
When using Accelerate, Prisma Client doesn't need a query engine. That's why you should generate it as follows:
60+
Generate Prisma Client with the following command:
6461

6562
```
66-
npx prisma generate --no-engine
63+
npx prisma generate
6764
```
6865

6966
### 5. Start the app

accelerate/astro-starter/package.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@
1313
"@astrojs/check": "0.9.5",
1414
"@astrojs/react": "4.3.0",
1515
"@astrojs/tailwind": "6.0.2",
16+
"@prisma/client": "7.0.0",
17+
"@prisma/extension-accelerate": "^2.0.2",
1618
"@types/react": "19.1.8",
1719
"@types/react-dom": "19.1.6",
1820
"astro": "5.10.2",
19-
"prisma": "6.9.0",
2021
"react": "19.1.0",
2122
"react-dom": "19.1.0",
2223
"tailwindcss": "3.4.17",
23-
"typescript": "5.8.2",
24-
"@prisma/client": "6.9.0",
25-
"@prisma/extension-accelerate": "2.0.2"
24+
"typescript": "5.8.2"
2625
},
2726
"devDependencies": {
28-
"prisma": "6.9.0",
27+
"prisma": "7.0.0",
2928
"tsx": "4.20.6"
30-
},
31-
"prisma": {
32-
"seed": "tsx prisma/seed.ts"
3329
}
34-
}
30+
}

0 commit comments

Comments
 (0)