fix fund fk on deletes
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m19s

This commit is contained in:
2026-03-18 23:14:33 -04:00
parent f54a332345
commit 20f939799d
+3 -1
View File
@@ -90,7 +90,9 @@ export async function DELETE(
const fund = await prisma.hedgeFund.findUnique({ where: { id: params.fundId } })
if (!fund) return NextResponse.json({ error: 'Fund not found.' }, { status: 404 })
// Delete shadow user cascades positions, trades, and the fund record
// Must delete fund first (it holds the FK to User), then delete the shadow user
// (which cascades positions and trades).
await prisma.hedgeFund.delete({ where: { id: fund.id } })
await prisma.user.delete({ where: { id: fund.userId } })
return NextResponse.json({ ok: true })