2023-08-02 12:44:51 -04:00
|
|
|
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)
|
2019-10-19 20:46:29 -04:00
|
|
|
);
|
|
|
|
|
2023-08-02 12:44:51 -04:00
|
|
|
CREATE VIEW user_mention_view AS
|
|
|
|
SELECT
|
2019-10-19 20:46:29 -04:00
|
|
|
c.id,
|
2023-08-02 12:44:51 -04:00
|
|
|
um.id AS user_mention_id,
|
2019-10-19 20:46:29 -04:00
|
|
|
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
|
2023-08-02 12:44:51 -04:00
|
|
|
FROM
|
|
|
|
user_mention um,
|
|
|
|
comment_view c
|
|
|
|
WHERE
|
|
|
|
um.comment_id = c.id;
|
|
|
|
|