feat: trigger for ctime on usertitle update
This commit is contained in:
parent
e999534b3f
commit
15a681c622
1 changed files with 15 additions and 2 deletions
|
|
@ -87,7 +87,7 @@ CREATE TABLE usertitles (
|
||||||
status usertitle_status_t NOT NULL,
|
status usertitle_status_t NOT NULL,
|
||||||
rate int CHECK (rate > 0 AND rate <= 10),
|
rate int CHECK (rate > 0 AND rate <= 10),
|
||||||
review_id bigint REFERENCES reviews (id),
|
review_id bigint REFERENCES reviews (id),
|
||||||
ctime timestamptz
|
ctime timestamptz NOT NULL DEFAULT now()
|
||||||
-- // TODO: series status
|
-- // TODO: series status
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -169,4 +169,17 @@ EXECUTE FUNCTION update_title_rating();
|
||||||
CREATE TRIGGER trg_notify_new_signal
|
CREATE TRIGGER trg_notify_new_signal
|
||||||
AFTER INSERT ON signals
|
AFTER INSERT ON signals
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION notify_new_signal();
|
EXECUTE FUNCTION notify_new_signal();
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION set_ctime()
|
||||||
|
RETURNS TRIGGER AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.ctime = now();
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE TRIGGER set_ctime_on_update
|
||||||
|
BEFORE UPDATE ON usertitles
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION set_ctime();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue