Demo data: three made-up repos and three people, recorded by the real Trail hooks.About TrailGitHub

Add unique constraints for webhook events and captures

Trail-Session: claude:68969d63-3984-4bbf-a591-a0175931b122 Trail-Link: http://localhost:8787/repos/payments-api/session/68969d63-3984-4bbf-a591-a0175931b122
Mmaya committed 9 days ago · maincommit 0e9e4d1febe1cf6d24615dcc330f1a7466d3396c
Agent sessions behind this commit1
Showing 1 changed file with 7 additions and 0 deletions.
migrations/0007_processed_events.sql+7 −0
@@ -0,0 +1,7 @@
+CREATE TABLE processed_events (
+ event_id text PRIMARY KEY,
+ processed_at timestamptz NOT NULL DEFAULT now()
+);
+
+-- one successful capture per order, whatever calls it
+CREATE UNIQUE INDEX captures_one_per_order ON captures (order_id) WHERE status = 'succeeded';