Skip to content

Commit bdfb389

Browse files
committed
explicitly set isolation level
1 parent e279227 commit bdfb389

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/db-utils.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
22
import { faker } from '@faker-js/faker'
3-
import { type PrismaClient } from '@prisma/client'
3+
import { Prisma, type PrismaClient } from '@prisma/client'
44
import bcrypt from 'bcryptjs'
55
import { UniqueEnforcer } from 'enforce-unique'
66

@@ -145,11 +145,16 @@ export async function cleanupDb(prisma: PrismaClient) {
145145
.filter(Boolean)
146146

147147
// Run each sql statement in the migration
148-
await prisma.$transaction([
149-
...statements.map((statement) =>
150-
prisma.$executeRawUnsafe(`${statement}`),
151-
),
152-
])
148+
await prisma.$transaction(
149+
[
150+
...statements.map((statement) =>
151+
prisma.$executeRawUnsafe(`${statement}`),
152+
),
153+
],
154+
{
155+
isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
156+
},
157+
)
153158
}
154159
} catch (error) {
155160
console.error('Error cleaning up database:', error)

0 commit comments

Comments
 (0)