Skip to content

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

Cascade delete participants

Luke Vella1707c5e0a05b
diff --git a/migrations/20220412115407_cascade_delete_participants/migration.sql b/migrations/20220412115407_cascade_delete_participants/migration.sql
new file mode 100644
index 000000000..11fc4ca27
--- /dev/null
+++ b/migrations/20220412115407_cascade_delete_participants/migration.sql
@@ -0,0 +1,5 @@
+-- DropForeignKey
+ALTER TABLE "Participant" DROP CONSTRAINT "Participant_pollId_fkey";
+
+-- AddForeignKey
+ALTER TABLE "Participant" ADD CONSTRAINT "Participant_pollId_fkey" FOREIGN KEY ("pollId") REFERENCES "Poll"("urlId") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/schema.prisma b/schema.prisma
index 07d1349d5..2db2f67fa 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -68,7 +68,7 @@ model Participant {
name String
user User? @relation(fields: [userId], references: [id])
userId String?
- poll Poll @relation(fields: [pollId], references: [urlId])
+ poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
pollId String
votes Vote[]
createdAt DateTime @default(now())