summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authormorkt <morkt@users.noreply.github.com>2015-10-18 12:32:05 +0400
committermorkt <morkt@users.noreply.github.com>2015-10-18 12:32:05 +0400
commitddbf3ae0ae530954b0e105e99819c85cfe4de17c (patch)
tree111cc30dd0311fd8754fa8a1d0572c8fc5d7e7c5 /util
parent710df2e42bb5558a611577ee6f374b4450b37f84 (diff)
discussion board polls.
Diffstat (limited to 'util')
-rw-r--r--util/sql/schema.sql24
1 files changed, 24 insertions, 0 deletions
diff --git a/util/sql/schema.sql b/util/sql/schema.sql
index 59240ea9..8dd960be 100644
--- a/util/sql/schema.sql
+++ b/util/sql/schema.sql
@@ -528,3 +528,27 @@ CREATE TABLE wlists (
added timestamptz NOT NULL DEFAULT NOW(),
PRIMARY KEY(uid, vid)
);
+
+CREATE TABLE polls (
+ id SERIAL PRIMARY KEY,
+ tid integer UNIQUE NOT NULL DEFAULT 0, -- references threads
+ question varchar(100) NOT NULL DEFAULT '',
+ max_options smallint NOT NULL DEFAULT 1,
+ preview boolean NOT NULL DEFAULT FALSE,
+ recast boolean NOT NULL DEFAULT FALSE
+);
+
+CREATE TABLE polls_options (
+ id SERIAL PRIMARY KEY,
+ pid integer NOT NULL REFERENCES polls (id) ON DELETE CASCADE,
+ option varchar(100) NOT NULL
+);
+
+CREATE TABLE polls_votes (
+ pid integer NOT NULL REFERENCES polls (id) ON DELETE CASCADE,
+ uid integer NOT NULL REFERENCES users (id) ON DELETE CASCADE,
+ optid integer NOT NULL REFERENCES polls_options (id) ON DELETE CASCADE,
+ PRIMARY KEY (pid, uid, optid)
+);
+
+ALTER TABLE polls ADD FOREIGN KEY (tid) REFERENCES threads (id) ON DELETE CASCADE;