Skip to content

Commit ea31a38

Browse files
committed
Use transaction client
Co-Authored-By: Aidan Jones <aidan_jones@sil.org>
1 parent de51294 commit ea31a38

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/lib/server/bullmq/queues.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type { Job } from 'bullmq';
22
import { Queue } from 'bullmq';
33
import { BullMQOtel } from 'bullmq-otel';
44
import { Redis } from 'ioredis';
5-
import { DatabaseWrites } from '../database';
6-
import prismaInternal, { DatabaseReads } from '../database/prisma';
5+
import prismaInternal from '../database/prisma';
76
import { Workflow } from '../workflow';
87
import type {
98
BaseJob,
@@ -118,8 +117,8 @@ let _queues: ReturnType<typeof createQueues> | undefined = undefined;
118117
async function createJobRecord(job: Job<BaseJob>) {
119118
try {
120119
if (job.id && job.data.transition) {
121-
await prismaInternal.$transaction(async () => {
122-
const existing = await DatabaseReads.productTransitions.findFirst({
120+
await prismaInternal.$transaction(async (tx) => {
121+
const existing = await tx.productTransitions.findFirst({
123122
where: { Id: job.data.transition }
124123
});
125124

@@ -138,7 +137,7 @@ async function createJobRecord(job: Job<BaseJob>) {
138137
}
139138
}
140139

141-
return await DatabaseWrites.queueRecords.create({
140+
return await tx.queueRecords.create({
142141
data: {
143142
ProductTransitionId: job.data.transition!,
144143
Queue: job.queueName,

0 commit comments

Comments
 (0)