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.
21 lines
591 B
PL/PgSQL
21 lines
591 B
PL/PgSQL
-- This file should undo anything in `up.sql`
|
|
CREATE OR REPLACE FUNCTION post_aggregates_post ()
|
|
RETURNS TRIGGER
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
BEGIN
|
|
IF (TG_OP = 'INSERT') THEN
|
|
INSERT INTO post_aggregates (post_id, published, newest_comment_time, newest_comment_time_necro)
|
|
VALUES (NEW.id, NEW.published, NEW.published, NEW.published);
|
|
ELSIF (TG_OP = 'DELETE') THEN
|
|
DELETE FROM post_aggregates
|
|
WHERE post_id = OLD.id;
|
|
END IF;
|
|
RETURN NULL;
|
|
END
|
|
$$;
|
|
|
|
ALTER TABLE post_aggregates
|
|
DROP COLUMN community_id,
|
|
DROP COLUMN creator_id;
|
|
|