add: polls backend
TODO: polls frontend
This commit is contained in:
parent
b5e060e8ae
commit
4dfa09207e
18 changed files with 574 additions and 17 deletions
|
@ -19,3 +19,5 @@ pub const CREATE_TABLE_UPLOADS: &str = include_str!("./sql/create_uploads.sql");
|
|||
pub const CREATE_TABLE_EMOJIS: &str = include_str!("./sql/create_emojis.sql");
|
||||
pub const CREATE_TABLE_STACKS: &str = include_str!("./sql/create_stacks.sql");
|
||||
pub const CREATE_TABLE_DRAFTS: &str = include_str!("./sql/create_drafts.sql");
|
||||
pub const CREATE_TABLE_POLLS: &str = include_str!("./sql/create_polls.sql");
|
||||
pub const CREATE_TABLE_POLLVOTES: &str = include_str!("./sql/create_pollvotes.sql");
|
||||
|
|
14
crates/core/src/database/drivers/sql/create_polls.sql
Normal file
14
crates/core/src/database/drivers/sql/create_polls.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
CREATE TABLE IF NOT EXISTS polls (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
owner BIGINT NOT NULL,
|
||||
created BIGINT NOT NULL,
|
||||
expires INT NOT NULL DEFAULT 86400000, -- expires in a day by default
|
||||
option_a TEXT NOT NULL,
|
||||
option_b TEXT NOT NULL,
|
||||
option_c TEXT NOT NULL,
|
||||
option_d TEXT NOT NULL,
|
||||
votes_a INT NOT NULL DEFAULT 0,
|
||||
votes_b INT NOT NULL DEFAULT 0,
|
||||
votes_c INT NOT NULL DEFAULT 0,
|
||||
votes_d INT NOT NULL DEFAULT 0
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
CREATE TABLE IF NOT EXISTS pollvotes (
|
||||
id BIGINT NOT NULL,
|
||||
owner BIGINT NOT NULL,
|
||||
created BIGINT NOT NULL,
|
||||
poll_id BIGINT NOT NULL,
|
||||
vote INT NOT NULL,
|
||||
PRIMARY KEY (owner, poll_id)
|
||||
)
|
|
@ -14,5 +14,6 @@ CREATE TABLE IF NOT EXISTS posts (
|
|||
-- ...
|
||||
uploads TEXT NOT NULL,
|
||||
is_deleted INT NOT NULL,
|
||||
tsvector_content tsvector GENERATED ALWAYS AS (to_tsvector ('english', coalesce(content, ''))) STORED
|
||||
tsvector_content tsvector GENERATED ALWAYS AS (to_tsvector ('english', coalesce(content, ''))) STORED,
|
||||
poll_id BIGINT NOT NULL
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue