Skip to content

Commit 82e984e

Browse files
authored
fix: create only one instance of prisma client (#348)
* fix prisma seed create only one instance of prisma client * db seed, import prisma client from singleton
1 parent 1e209b1 commit 82e984e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

prisma/seed.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import type { Interval } from '#app/modules/stripe/plans'
2-
import { PrismaClient } from '@prisma/client'
3-
import { prisma } from '#app/utils/db.server'
42
import { stripe } from '#app/modules/stripe/stripe.server'
53
import { PRICING_PLANS } from '#app/modules/stripe/plans'
6-
7-
const client = new PrismaClient()
4+
import { prisma } from '#app/utils/db.server.ts'
85

96
async function seed() {
107
/**
@@ -157,10 +154,11 @@ async function seed() {
157154
}
158155

159156
seed()
160-
.catch((err: unknown) => {
157+
.catch(async (err) => {
161158
console.error(err)
159+
await prisma.$disconnect()
162160
process.exit(1)
163161
})
164-
.finally(async () => {
165-
await client.$disconnect()
162+
.then(async () => {
163+
await prisma.$disconnect()
166164
})

0 commit comments

Comments
 (0)