aboutsummaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-03-01 17:13:49 +0200
committerJan Tuomi <jan@jantuomi.fi>2024-12-21 19:43:13 +0200
commitc02d685c996b8155781b5df658ee13653893eb8a (patch)
treea485f3b574e0c82846d9e4d16049810e20bb79bf /migrations
parentb318694bfe4378f9d98e4cde94269cc209c9df39 (diff)
Improve validation
Diffstat (limited to 'migrations')
-rw-r--r--migrations/0005_indices.sql7
1 files changed, 7 insertions, 0 deletions
diff --git a/migrations/0005_indices.sql b/migrations/0005_indices.sql
new file mode 100644
index 0000000..83d0d09
--- /dev/null
+++ b/migrations/0005_indices.sql
@@ -0,0 +1,7 @@
+ALTER TABLE votes ADD CONSTRAINT idx_votes_unique_voter_name UNIQUE (poll_id, choice_id, voter_name);
+
+CREATE INDEX idx_votes_poll_id_voter_name ON votes (poll_id, voter_name);
+CREATE INDEX idx_choices_poll_id_start_datetime ON choices (poll_id, start_datetime);
+CREATE INDEX idx_votes_choice_id ON votes (choice_id);
+CREATE INDEX idx_votes_manage_code ON votes (manage_code);
+CREATE INDEX idx_polls_manage_code_pub_date ON polls (manage_code, pub_date);