Skip to content

Commit

Permalink
explicitly set isolation level
Browse files Browse the repository at this point in the history
  • Loading branch information
devneill committed Sep 28, 2024
1 parent e279227 commit bdfb389
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/db-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'
import { faker } from '@faker-js/faker'
import { type PrismaClient } from '@prisma/client'
import { Prisma, type PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'
import { UniqueEnforcer } from 'enforce-unique'

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

// Run each sql statement in the migration
await prisma.$transaction([
...statements.map((statement) =>
prisma.$executeRawUnsafe(`${statement}`),
),
])
await prisma.$transaction(
[
...statements.map((statement) =>
prisma.$executeRawUnsafe(`${statement}`),
),
],
{
isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
},
)
}
} catch (error) {
console.error('Error cleaning up database:', error)
Expand Down

0 comments on commit bdfb389

Please sign in to comment.