CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
schema-events.ts
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 | /** |
| 2 | * Signal Bus P1 — Drizzle schema for the inbound-event idempotency table. | |
| 3 | * | |
| 4 | * Defined in a SEPARATE module because `src/db/schema.ts` is listed in | |
| 5 | * §4 LOCKED BLOCKS of BUILD_BIBLE.md and must not be edited. New tables are | |
| 6 | * allowed "only via new migration"; this module supplies the matching Drizzle | |
| 7 | * definitions that migration `drizzle/0034_processed_events.sql` creates at | |
| 8 | * the SQL layer. Import `processedEvents` directly from this module. | |
| 9 | * | |
| 10 | * Columns mirror the SQL migration 1:1. Keep them in sync whenever the | |
| 11 | * migration is superseded by a follow-up additive migration. | |
| 12 | */ | |
| 13 | ||
| 14 | import { index, jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; | |
| 15 | ||
| 16 | export const processedEvents = pgTable( | |
| 17 | "processed_events", | |
| 18 | { | |
| 19 | id: uuid("id").primaryKey().defaultRandom(), | |
| 20 | eventId: text("event_id").notNull().unique(), | |
| 21 | eventType: text("event_type").notNull(), | |
| 22 | source: text("source").notNull(), | |
| 23 | receivedAt: timestamp("received_at").defaultNow().notNull(), | |
| 24 | // Raw payload retained for forensics / replay. jsonb column — callers | |
| 25 | // pass a plain object and drizzle serialises it. | |
| 26 | payload: jsonb("payload"), | |
| 27 | }, | |
| 28 | (table) => [ | |
| 29 | index("processed_events_event_id_idx").on(table.eventId), | |
| 30 | index("processed_events_source_type_idx").on(table.source, table.eventType), | |
| 31 | ] | |
| 32 | ); |