Skip to content

Commit 5e40cf2

Browse files
committed
Set up Prisma client on deploy
1 parent de6a379 commit 5e40cf2

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
functions = "out_functions"
33
publish = "out_publish"
4-
command = ""
4+
command = "npm run prisma"
55

66
[build.environment]
77
# Fix to ensure the Prisma binary is packaged with the lambda function

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7+
"prisma": "prisma generate",
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},
910
"keywords": [],
@@ -14,5 +15,8 @@
1415
"next": "^9.5.5",
1516
"react": "^16.14.0",
1617
"react-dom": "^16.14.0"
18+
},
19+
"devDependencies": {
20+
"@prisma/cli": "^2.9.0"
1721
}
1822
}

prisma/schema.prisma

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
binaryTargets = ["native", "rhel-openssl-1.0.x"]
4+
}
5+
6+
datasource db {
7+
provider = "postgresql"
8+
url = env("DATABASE_URL")
9+
}
10+
11+
model Post {
12+
id Int @default(autoincrement()) @id
13+
createdAt DateTime @default(now())
14+
title String
15+
content String?
16+
published Boolean @default(false)
17+
author User @relation(fields: [authorId], references: [id]) // renamed from `User` -> `author`
18+
authorId Int // relation scalar field
19+
}
20+
21+
model Profile {
22+
id Int @default(autoincrement()) @id
23+
bio String?
24+
userId Int @unique // relation scalar field
25+
user User @relation(fields: [userId], references: [id]) // renamed from `User` -> `user`
26+
}
27+
28+
model User {
29+
id Int @default(autoincrement()) @id
30+
email String @unique
31+
name String?
32+
posts Post[] // renamed from `Post` -> `posts`
33+
profile Profile? // renamed from `User` -> `profile`
34+
}

0 commit comments

Comments
 (0)