CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0034_processed_events.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| b45db84 | 1 | -- Signal Bus P1 — Idempotency table for inbound events. |
| 2 | -- | |
| 3 | -- Records every external event we have successfully processed so that | |
| 4 | -- duplicate deliveries (Crontech retry, network replay, at-least-once bus) | |
| 5 | -- can be detected and short-circuited without firing side-effects twice. | |
| 6 | -- | |
| 7 | -- `event_id` is the provider-supplied uuid v4 carried on the wire. | |
| 8 | -- `source` namespaces event_id in case two providers happen to collide | |
| 9 | -- (e.g. 'crontech', 'gatetest', 'github'). | |
| 10 | -- | |
| 11 | -- This migration is additive and reversible — drop the table to remove it. | |
| 12 | ||
| 13 | CREATE TABLE IF NOT EXISTS "processed_events" ( | |
| 14 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 15 | "event_id" text NOT NULL UNIQUE, | |
| 16 | "event_type" text NOT NULL, | |
| 17 | "source" text NOT NULL, | |
| 18 | "received_at" timestamp NOT NULL DEFAULT now(), | |
| 19 | "payload" jsonb | |
| 20 | ); | |
| 21 | ||
| 22 | --> statement-breakpoint | |
| 23 | ||
| 24 | CREATE INDEX IF NOT EXISTS "processed_events_event_id_idx" | |
| 25 | ON "processed_events" ("event_id"); | |
| 26 | ||
| 27 | --> statement-breakpoint | |
| 28 | ||
| 29 | CREATE INDEX IF NOT EXISTS "processed_events_source_type_idx" | |
| 30 | ON "processed_events" ("source", "event_type"); |