Fix account delete blocked by CsvUpload FK constraint
Add onDelete: Cascade to CsvUpload.accountId so deleting an account cascades to its upload records. Also explicitly delete uploads before the account in the API route so existing deployed DBs without the constraint don't error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,7 @@ export async function DELETE(_req: Request, { params }: Params) {
|
||||
})
|
||||
if (!existing) return NextResponse.json({ error: 'Not found' }, { status: 404 })
|
||||
|
||||
await prisma.csvUpload.deleteMany({ where: { accountId: id } })
|
||||
await prisma.account.delete({ where: { id } })
|
||||
return new NextResponse(null, { status: 204 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user