diff --git a/apps/web/src/trpc/routers/user.ts b/apps/web/src/trpc/routers/user.ts index 64a83a5a3..1a3b426fc 100644 --- a/apps/web/src/trpc/routers/user.ts +++ b/apps/web/src/trpc/routers/user.ts @@ -59,9 +59,13 @@ export const user = router({ where: { userId: ctx.user.id }, }); const pollIds = polls.map((poll) => poll.id); - await tx.comment.deleteMany({ + + await tx.vote.deleteMany({ where: { pollId: { in: pollIds } }, }); + await tx.comment.deleteMany({ + where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] }, + }); await tx.option.deleteMany({ where: { pollId: { in: pollIds } }, }); @@ -71,15 +75,9 @@ export const user = router({ await tx.watcher.deleteMany({ where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] }, }); - await tx.vote.deleteMany({ - where: { pollId: { in: pollIds } }, - }); await tx.event.deleteMany({ where: { userId: ctx.user.id }, }); - await tx.comment.deleteMany({ - where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] }, - }); await tx.poll.deleteMany({ where: { userId: ctx.user.id }, });