mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +02:00
✨ Soft delete participants (#1193)
This commit is contained in:
parent
8384128246
commit
6df4405cf4
3 changed files with 11 additions and 1 deletions
|
@ -18,6 +18,7 @@ export const participants = router({
|
|||
const participants = await prisma.participant.findMany({
|
||||
where: {
|
||||
pollId,
|
||||
deleted: false,
|
||||
},
|
||||
include: {
|
||||
votes: {
|
||||
|
@ -43,10 +44,14 @@ export const participants = router({
|
|||
}),
|
||||
)
|
||||
.mutation(async ({ input: { participantId } }) => {
|
||||
await prisma.participant.delete({
|
||||
await prisma.participant.update({
|
||||
where: {
|
||||
id: participantId,
|
||||
},
|
||||
data: {
|
||||
deleted: true,
|
||||
deletedAt: new Date(),
|
||||
},
|
||||
});
|
||||
}),
|
||||
add: publicProcedure
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "participants" ADD COLUMN "deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "deleted_at" TIMESTAMP(3);
|
|
@ -188,6 +188,8 @@ model Participant {
|
|||
votes Vote[]
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
deleted Boolean @default(false)
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
@@index([pollId], type: Hash)
|
||||
@@map("participants")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue