Skip to content

Commit 042d233

Browse files
update cockroachdb, postgresql-supabase, prisma-postgres examples (#8374)
1 parent e6a2d3c commit 042d233

File tree

17 files changed

+1263
-51
lines changed

17 files changed

+1263
-51
lines changed

databases/cockroachdb/bun.lock

Lines changed: 754 additions & 0 deletions
Large diffs are not rendered by default.

databases/cockroachdb/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
"author": "",
77
"main": "index.js",
88
"scripts": {
9-
"start": "ts-node ./src/script.ts",
9+
"start": "tsx ./src/script.ts",
1010
"test": "jest",
1111
"test:watch": "jest --watch"
1212
},
1313
"dependencies": {
14-
"@prisma/client": "6.9.0",
14+
"@prisma/adapter-pg": "6.20.0-integration-next.3",
15+
"@prisma/client": "6.20.0-integration-next.3",
16+
"dotenv": "16.6.1",
1517
"jest": "29.7.0"
1618
},
1719
"devDependencies": {
1820
"@types/jest": "29.5.14",
1921
"@types/node": "22.19.0",
2022
"@types/prettyjson": "0.0.33",
2123
"prettyjson": "1.2.5",
22-
"prisma": "6.9.0",
24+
"prisma": "6.20.0-integration-next.3",
2325
"ts-jest": "29.4.5",
24-
"ts-node": "10.9.2",
25-
"ts-node-dev": "2.0.0",
26+
"tsx": "^4.20.6",
2627
"typescript": "5.8.2"
2728
}
28-
}
29+
}

databases/cockroachdb/prisma/schema.prisma

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
generator client {
2-
provider = "prisma-client-js"
2+
provider = "prisma-client"
3+
output = "./generated"
4+
engineType = "client"
35
}
46

57
datasource db {
@@ -25,7 +27,7 @@ model Post {
2527
authorId String
2628
author User @relation(fields: [authorId], references: [id])
2729
comments Comment[]
28-
tags Tag[]
30+
tags Tag[]
2931
}
3032

3133
model Comment {

databases/cockroachdb/src/script.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import { PrismaClient } from '@prisma/client'
1+
import { PrismaClient } from '../prisma/generated/client'
22
import prettyjson from 'prettyjson'
3+
import { PrismaPg } from '@prisma/adapter-pg'
4+
import 'dotenv/config'
35

4-
const prisma = new PrismaClient()
6+
const adapter = new PrismaPg({
7+
connectionString: process.env.DATABASE_URL,
8+
})
9+
const prisma = new PrismaClient({
10+
adapter,
11+
})
512

613
// A `main` function so that we can use async/await
714
async function main() {

databases/cockroachdb/tests/prisma.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import { PrismaClient } from '@prisma/client'
1+
import { PrismaClient } from '../prisma/generated/client'
2+
import { PrismaPg } from '@prisma/adapter-pg'
3+
import 'dotenv/config'
24

3-
export const prisma = new PrismaClient()
5+
const adapter = new PrismaPg({
6+
connectionString: process.env.DATABASE_URL,
7+
})
8+
export const prisma = new PrismaClient({
9+
adapter,
10+
})
411

512
describe('example test with Prisma Client', () => {
613
beforeAll(async () => {

databases/postgresql-supabase/bun.lock

Lines changed: 245 additions & 0 deletions
Large diffs are not rendered by default.

databases/postgresql-supabase/package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"dev": "ts-node script.ts",
6+
"dev": "tsx script.ts",
77
"test": "jest",
88
"test:watch": "jest --watch"
99
},
1010
"devDependencies": {
11-
"@types/node": "22.19.0",
12-
"prisma": "6.9.0",
11+
"@types/node": "22.18.12",
12+
"prisma": "6.20.0-integration-next.3",
1313
"supabase": "2.30.4",
14-
"ts-node": "10.9.2",
15-
"typescript": "5.8.2"
14+
"typescript": "5.8.2",
15+
"tsx": "^4.20.6"
1616
},
1717
"dependencies": {
18-
"@prisma/client": "6.9.0"
19-
},
20-
"prisma": {
21-
"seed": "ts-node prisma/seed.ts"
18+
"@prisma/adapter-pg": "6.20.0-integration-next.3",
19+
"@prisma/client": "6.20.0-integration-next.3"
2220
}
23-
}
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
},
9+
datasource: {
10+
url: env("DATABASE_URL"),
11+
},
12+
});

databases/postgresql-supabase/prisma/schema.prisma

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// learn more about it in the docs: https://pris.ly/d/prisma-schema
33

44
generator client {
5-
provider = "prisma-client-js"
5+
provider = "prisma-client"
6+
output = "./generated"
7+
engineType = "client"
68
}
79

810
datasource db {
9-
provider = "postgresql"
10-
url = env("DATABASE_URL")
11+
provider = "postgresql"
12+
url = env("DATABASE_URL")
1113
}
1214

1315
model User {

databases/postgresql-supabase/prisma/seed.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { PrismaClient, Prisma } from '@prisma/client'
1+
import { PrismaClient, Prisma } from './generated/client'
2+
import {PrismaPg} from "@prisma/adapter-pg"
23

3-
const prisma = new PrismaClient();
4+
const adapter = new PrismaPg({
5+
connectionString: process.env.DATABASE_URL,
6+
})
7+
const prisma = new PrismaClient({
8+
adapter,
9+
});
410

511
const userData = [
612
{

0 commit comments

Comments
 (0)