Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Soft delete participants (#1193)

Luke Vella6df4405cf410
diff --git a/packages/backend/trpc/routers/polls/participants.ts b/packages/backend/trpc/routers/polls/participants.ts
index aabd5b943..fc3a8e109 100644
--- a/packages/backend/trpc/routers/polls/participants.ts
+++ b/packages/backend/trpc/routers/polls/participants.ts
@@ -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
diff --git a/packages/database/prisma/migrations/20240704085250_soft_delete_participants/migration.sql b/packages/database/prisma/migrations/20240704085250_soft_delete_participants/migration.sql
new file mode 100644
index 000000000..4b0268d74
--- /dev/null
+++ b/packages/database/prisma/migrations/20240704085250_soft_delete_participants/migration.sql
@@ -0,0 +1,3 @@
+-- AlterTable
+ALTER TABLE "participants" ADD COLUMN "deleted" BOOLEAN NOT NULL DEFAULT false,
+ADD COLUMN "deleted_at" TIMESTAMP(3);
diff --git a/packages/database/prisma/schema.prisma b/packages/database/prisma/schema.prisma
index cb2665613..633bc3873 100644
--- a/packages/database/prisma/schema.prisma
+++ b/packages/database/prisma/schema.prisma
@@ -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")