Update house keeping tasks

This commit is contained in:
Luke Vella 2024-12-17 19:07:21 +00:00
parent d58ed5fddd
commit d73a2f53ef
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
6 changed files with 63 additions and 69 deletions

View file

@ -0,0 +1,14 @@
-- CreateIndex
CREATE INDEX "comments_poll_id_idx" ON "comments"("poll_id");
-- CreateIndex
CREATE INDEX "options_poll_id_idx" ON "options"("poll_id");
-- CreateIndex
CREATE INDEX "participants_poll_id_idx" ON "participants"("poll_id");
-- CreateIndex
CREATE INDEX "polls_deleted_touched_at_idx" ON "polls"("deleted", "touched_at");
-- CreateIndex
CREATE INDEX "votes_poll_id_idx" ON "votes"("poll_id");

View file

@ -0,0 +1,32 @@
-- DropIndex
DROP INDEX "comments_poll_id_idx";
-- DropIndex
DROP INDEX "options_poll_id_idx";
-- DropIndex
DROP INDEX "participants_poll_id_idx";
-- DropIndex
DROP INDEX "votes_poll_id_idx";
-- CreateIndex
CREATE INDEX "comments_poll_id_idx" ON "comments" USING HASH ("poll_id");
-- CreateIndex
CREATE INDEX "options_poll_id_idx" ON "options" USING HASH ("poll_id");
-- CreateIndex
CREATE INDEX "participants_poll_id_idx" ON "participants" USING HASH ("poll_id");
-- CreateIndex
CREATE INDEX "votes_poll_id_idx" ON "votes" USING HASH ("poll_id");
-- CreateIndex
CREATE INDEX "votes_participant_id_idx" ON "votes" USING HASH ("participant_id");
-- CreateIndex
CREATE INDEX "votes_option_id_idx" ON "votes" USING HASH ("option_id");
-- CreateIndex
CREATE INDEX "watchers_poll_id_idx" ON "watchers" USING HASH ("poll_id");

View file

@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX "polls_deleted_deleted_at_idx" ON "polls"("deleted", "deleted_at");

View file

@ -146,6 +146,8 @@ model Poll {
comments Comment[] @relation("PollToComments")
votes Vote[] @relation("PollToVotes")
@@index([deleted, touchedAt])
@@index([deleted, deletedAt])
@@map("polls")
}
@ -173,6 +175,7 @@ model Watcher {
poll Poll @relation("PollToWatchers", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("watchers")
}
@ -181,7 +184,6 @@ model Participant {
name String
email String?
userId String? @map("user_id")
poll Poll @relation("PollToParticipants", fields: [pollId], references: [id], onDelete: Cascade)
pollId String @map("poll_id")
locale String?
createdAt DateTime @default(now()) @map("created_at")
@ -190,7 +192,9 @@ model Participant {
deletedAt DateTime? @map("deleted_at")
votes Vote[] @relation("ParticipantToVotes")
poll Poll @relation("PollToParticipants", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("participants")
}
@ -202,6 +206,7 @@ model Option {
poll Poll @relation("PollToOptions", fields: [pollId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @map("created_at")
@@index([pollId], type: Hash)
@@map("options")
}
@ -225,6 +230,9 @@ model Vote {
participant Participant @relation("ParticipantToVotes", fields: [participantId], references: [id], onDelete: Cascade)
poll Poll @relation("PollToVotes", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@index([participantId], type: Hash)
@@index([optionId], type: Hash)
@@map("votes")
}
@ -240,6 +248,7 @@ model Comment {
poll Poll @relation("PollToComments", fields: [pollId], references: [id], onDelete: Cascade)
@@index([pollId], type: Hash)
@@map("comments")
}