lemmy/migrations/2024-10-17-091053_vote-no-timestamp/down.sql

23 lines
520 B
SQL

ALTER TABLE post_like
ADD COLUMN published timestamptz NOT NULL DEFAULT now();
ALTER TABLE comment_like
ADD COLUMN published timestamptz NOT NULL DEFAULT now();
ALTER TABLE comment_like
ADD COLUMN post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE;
UPDATE
comment_like
SET
post_id = (
SELECT
post_id
FROM
comment
WHERE
comment.id = comment_like.comment_id);
ALTER TABLE comment_like
ALTER COLUMN post_id SET NOT NULL;