mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 17:54:21 +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.
40 lines
843 B
SQL
40 lines
843 B
SQL
CREATE TABLE user_mention (
|
|
id serial PRIMARY KEY,
|
|
recipient_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,
|
|
read boolean DEFAULT FALSE NOT NULL,
|
|
published timestamp NOT NULL DEFAULT now(),
|
|
UNIQUE (recipient_id, comment_id)
|
|
);
|
|
|
|
CREATE VIEW user_mention_view AS
|
|
SELECT
|
|
c.id,
|
|
um.id AS user_mention_id,
|
|
c.creator_id,
|
|
c.post_id,
|
|
c.parent_id,
|
|
c.content,
|
|
c.removed,
|
|
um.read,
|
|
c.published,
|
|
c.updated,
|
|
c.deleted,
|
|
c.community_id,
|
|
c.banned,
|
|
c.banned_from_community,
|
|
c.creator_name,
|
|
c.score,
|
|
c.upvotes,
|
|
c.downvotes,
|
|
c.user_id,
|
|
c.my_vote,
|
|
c.saved,
|
|
um.recipient_id
|
|
FROM
|
|
user_mention um,
|
|
comment_view c
|
|
WHERE
|
|
um.comment_id = c.id;
|
|
|