mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-05 04:00:02 +00:00
be1389420b
* SQL format checking, 1. * SQL format checking, 2. * SQL format checking, 3. * SQL format checking, 4. * SQL format checking, 5. * Running pg_format * Getting rid of comment. * Upping pg_format version. * Using git ls-files for sql format check. * Fixing sql lints. * Addressing PR comments.
30 lines
1.2 KiB
SQL
30 lines
1.2 KiB
SQL
CREATE TABLE comment (
|
|
id serial PRIMARY KEY,
|
|
creator_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
parent_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
|
|
content text NOT NULL,
|
|
removed boolean DEFAULT FALSE NOT NULL,
|
|
read boolean DEFAULT FALSE NOT NULL,
|
|
published timestamp NOT NULL DEFAULT now(),
|
|
updated timestamp
|
|
);
|
|
|
|
CREATE TABLE comment_like (
|
|
id serial PRIMARY KEY,
|
|
user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
comment_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
score smallint NOT NULL, -- -1, or 1 for dislike, like, no row for no opinion
|
|
published timestamp NOT NULL DEFAULT now(),
|
|
UNIQUE (comment_id, user_id)
|
|
);
|
|
|
|
CREATE TABLE comment_saved (
|
|
id serial PRIMARY KEY,
|
|
comment_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
published timestamp NOT NULL DEFAULT now(),
|
|
UNIQUE (comment_id, user_id)
|
|
);
|
|
|