refactor(yachts): use withTransaction helper per project convention

This commit is contained in:
Matt Ciaccio
2026-04-23 23:47:12 +02:00
parent feacb8c7ac
commit aaf4847fc2

View File

@@ -5,6 +5,7 @@ import { companies } from '@/lib/db/schema/companies';
import { createAuditLog } from '@/lib/audit'; import { createAuditLog } from '@/lib/audit';
import { NotFoundError, ValidationError } from '@/lib/errors'; import { NotFoundError, ValidationError } from '@/lib/errors';
import { emitToRoom } from '@/lib/socket/server'; import { emitToRoom } from '@/lib/socket/server';
import { withTransaction } from '@/lib/db/utils';
import type { z } from 'zod'; import type { z } from 'zod';
import type { createYachtSchema } from '@/lib/validators/yachts'; import type { createYachtSchema } from '@/lib/validators/yachts';
@@ -36,8 +37,8 @@ async function assertOwnerExists(
} }
export async function createYacht(portId: string, data: CreateYachtInput, meta: AuditMeta) { export async function createYacht(portId: string, data: CreateYachtInput, meta: AuditMeta) {
return await db.transaction(async (tx) => { return await withTransaction(async (tx) => {
await assertOwnerExists(portId, data.owner, tx as unknown as typeof db); await assertOwnerExists(portId, data.owner, tx);
const [yacht] = await tx const [yacht] = await tx
.insert(yachts) .insert(yachts)