Skip to content

Commit ca037c6

Browse files
committed
Trigger runner_progress.updated_at on UPDATE
1 parent 0577ceb commit ca037c6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Ensure runner_progress.updated_at is bumped on every UPDATE.
2+
-- Without this, upserts from BaseRunner only refresh total/completed/failed
3+
-- and updated_at stays pinned at the INSERT default, making it impossible
4+
-- to distinguish live runs from zombies via timestamp.
5+
6+
CREATE OR REPLACE FUNCTION set_updated_at()
7+
RETURNS TRIGGER
8+
LANGUAGE plpgsql
9+
AS $$
10+
BEGIN
11+
NEW.updated_at = now();
12+
RETURN NEW;
13+
END;
14+
$$;
15+
16+
DROP TRIGGER IF EXISTS runner_progress_set_updated_at ON runner_progress;
17+
CREATE TRIGGER runner_progress_set_updated_at
18+
BEFORE UPDATE ON runner_progress
19+
FOR EACH ROW
20+
EXECUTE FUNCTION set_updated_at();

0 commit comments

Comments
 (0)