-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
34 lines (28 loc) · 820 Bytes
/
schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- PostgreSQL schema for betterpoll
BEGIN TRANSACTION;
CREATE TABLE polls (
-- Doubles as the URL
id TEXT NOT NULL PRIMARY KEY,
title TEXT NOT NULL,
description TEXT NOT NULL,
candidates TEXT[] NOT NULL,
prohibit_double_vote_by_ip BOOLEAN NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
num_winners INTEGER NOT NULL,
-- 0 for Schulze
method INTEGER NOT NULL
);
CREATE TABLE votes (
poll_id TEXT NOT NULL REFERENCES polls(id),
voter_ip INET NOT NULL,
-- Reserved for future use
voter_fingerprint TEXT,
-- 1st choice is in preferences[0], etc.
preferences TEXT[] NOT NULL
);
CREATE TABLE db_info (
version INTEGER NOT NULL
);
INSERT INTO db_info (version) VALUES (1);
COMMIT;