Skip to content

Commit d5fd888

Browse files
Upgrade to prisma 7
upgrade to prisma 7
2 parents ddd863d + ad46039 commit d5fd888

File tree

8 files changed

+2409
-565
lines changed

8 files changed

+2409
-565
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
.next/
3-
.env
3+
.env
4+
/prisma/generated

components/Header.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ const Header: React.FC = () => {
1212

1313
let left = (
1414
<div className="left">
15-
<Link href="/">
16-
<a className="bold" data-active={isActive("/")}>
17-
Feed
18-
</a>
15+
<Link href="/" className="bold" data-active={isActive("/")}>
16+
Feed
1917
</Link>
2018
<style jsx>{`
2119
.bold {
@@ -44,10 +42,8 @@ const Header: React.FC = () => {
4442
if (status === 'loading') {
4543
left = (
4644
<div className="left">
47-
<Link href="/">
48-
<a className="bold" data-active={isActive("/")}>
49-
Feed
50-
</a>
45+
<Link href="/" className="bold" data-active={isActive("/")}>
46+
Feed
5147
</Link>
5248
<style jsx>{`
5349
.bold {
@@ -85,8 +81,8 @@ const Header: React.FC = () => {
8581
if (!session) {
8682
right = (
8783
<div className="right">
88-
<Link href="/api/auth/signin">
89-
<a data-active={isActive("/signup")}>Log in</a>
84+
<Link href="/api/auth/signin" data-active={isActive("/signup")}>
85+
Log in
9086
</Link>
9187
<style jsx>{`
9288
a {
@@ -116,13 +112,11 @@ const Header: React.FC = () => {
116112
if (session) {
117113
left = (
118114
<div className="left">
119-
<Link href="/">
120-
<a className="bold" data-active={isActive("/")}>
121-
Feed
122-
</a>
115+
<Link href="/" className="bold" data-active={isActive("/")}>
116+
Feed
123117
</Link>
124-
<Link href="/drafts">
125-
<a data-active={isActive("/drafts")}>My drafts</a>
118+
<Link href="/drafts" data-active={isActive("/drafts")}>
119+
My drafts
126120
</Link>
127121
<style jsx>{`
128122
.bold {
@@ -151,12 +145,10 @@ const Header: React.FC = () => {
151145
{session.user.name} ({session.user.email})
152146
</p>
153147
<Link href="/create">
154-
<button>
155-
<a>New post</a>
156-
</button>
148+
<button>New post</button>
157149
</Link>
158150
<button onClick={() => signOut()}>
159-
<a>Log out</a>
151+
Log out
160152
</button>
161153
<style jsx>{`
162154
a {

lib/prisma.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PrismaClient } from "@prisma/client";
1+
import { PrismaClient } from "../prisma/generated/client";
2+
import { PrismaPg } from "@prisma/adapter-pg";
23

34
// PrismaClient is attached to the `global` object in development to prevent
45
// exhausting your database connection limit.
@@ -8,11 +9,18 @@ import { PrismaClient } from "@prisma/client";
89

910
let prisma: PrismaClient
1011

12+
const adapter = new PrismaPg({
13+
connectionString: process.env.DATABASE_URL,
14+
})
1115
if (process.env.NODE_ENV === 'production') {
12-
prisma = new PrismaClient()
16+
prisma = new PrismaClient({
17+
adapter,
18+
})
1319
} else {
1420
if (!global.prisma) {
15-
global.prisma = new PrismaClient()
21+
global.prisma = new PrismaClient({
22+
adapter,
23+
})
1624
}
1725
prisma = global.prisma
1826
}

0 commit comments

Comments
 (0)