Skip to content

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

Cascade delete votes

Luke Vellac8d3811daf87
diff --git a/migrations/20220412115744_cascade_delete_votes/migration.sql b/migrations/20220412115744_cascade_delete_votes/migration.sql
new file mode 100644
index 000000000..af0b86400
--- /dev/null
+++ b/migrations/20220412115744_cascade_delete_votes/migration.sql
@@ -0,0 +1,5 @@
+-- DropForeignKey
+ALTER TABLE "Vote" DROP CONSTRAINT "Vote_pollId_fkey";
+
+-- AddForeignKey
+ALTER TABLE "Vote" ADD CONSTRAINT "Vote_pollId_fkey" FOREIGN KEY ("pollId") REFERENCES "Poll"("urlId") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/schema.prisma b/schema.prisma
index 2db2f67fa..2f24e315d 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -89,7 +89,7 @@ model Vote {
participantId String
option Option @relation(fields: [optionId], references: [id], onDelete: Cascade)
optionId String
- poll Poll @relation(fields: [pollId], references: [urlId])
+ poll Poll @relation(fields: [pollId], references: [urlId], onDelete: Cascade)
pollId String
}