mirror of
https://gitlab.com/commento/commento.git
synced 2025-04-28 18:40:29 -04:00
16 lines
437 B
PL/PgSQL
16 lines
437 B
PL/PgSQL
ALTER TABLE pages
|
|
ADD commentCount INTEGER NOT NULL DEFAULT 0;
|
|
|
|
CREATE OR REPLACE FUNCTION commentsInsertTriggerFunction() RETURNS TRIGGER AS $trigger$
|
|
BEGIN
|
|
UPDATE pages
|
|
SET commentCount = commentCount + 1
|
|
WHERE domain = new.domain AND path = new.path;
|
|
|
|
RETURN NEW;
|
|
END;
|
|
$trigger$ LANGUAGE plpgsql;
|
|
|
|
CREATE TRIGGER commentsInsertTrigger AFTER INSERT ON comments
|
|
FOR EACH ROW EXECUTE PROCEDURE commentsInsertTriggerFunction();
|