mirror of
https://codeberg.org/catask-org/catask.git
synced 2025-04-16 12:13:42 -05:00
27 lines
988 B
SQL
27 lines
988 B
SQL
CREATE TABLE IF NOT EXISTS answers (
|
|
id SERIAL PRIMARY KEY,
|
|
question_id INTEGER NOT NULL,
|
|
creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
content TEXT NOT NULL,
|
|
cw VARCHAR(255) NOT NULL DEFAULT ''
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS questions (
|
|
id SERIAL PRIMARY KEY,
|
|
from_who VARCHAR(255) NOT NULL,
|
|
creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
content TEXT NOT NULL,
|
|
answered BOOLEAN NOT NULL DEFAULT FALSE,
|
|
answer_id INTEGER,
|
|
pinned BOOLEAN NOT NULL DEFAULT FALSE,
|
|
cw VARCHAR(255) NOT NULL DEFAULT '',
|
|
unread BOOLEAN NOT NULL DEFAULT TRUE
|
|
-- private BOOLEAN NOT NULL DEFAULT FALSE, -- For later use
|
|
-- user_ip BYTEA NOT NULL DEFAULT '' -- For later use
|
|
);
|
|
|
|
ALTER TABLE questions
|
|
ADD CONSTRAINT fk_answer_id FOREIGN KEY (answer_id) REFERENCES answers(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE answers
|
|
ADD CONSTRAINT fk_question_id FOREIGN KEY (question_id) REFERENCES questions(id) ON DELETE CASCADE;
|