public.email_events
Synced from
docs/generated/erd/— do not hand-edit.
Regenerate withbun run docs:erd(needs staging reader), then this script runs automatically.
Labels:docs/db/erd-table-labels.yml· Runbook:docs/runbooks/erd-schema-docs.md
Description
Section titled “Description”First-party campaign engagement events (campaign_id, member_id) — Not: email_webhook_events — raw provider callbacks, not our own events
Columns
Section titled “Columns”| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| campaign_id | uuid | true | email_campaigns |
|||
| created_at | timestamp with time zone | now() | false | |||
| event_type | text | false | ||||
| id | uuid | gen_random_uuid() | false | |||
| member_id | uuid | true | public.members | |||
| metadata | jsonb | ‘{}’::jsonb | true | |||
| org_id | text | ‘’::text | false | organizations |
Viewpoints
Section titled “Viewpoints”| Name | Definition |
|---|---|
| Communications & Journeys | Email campaigns, segments, templates, send/hygiene state, and journey engine (journeys/nodes/edges/runs). Catalog §4.1, §4.4. # email_automations + automation_executions dropped #2213 (P3 UNIT 2) — # journeys.* is the live automation surface; do not re-list those tables here. |
Constraints
Section titled “Constraints”| Name | Type | Definition |
|---|---|---|
| email_events_campaign_id_fkey | FOREIGN KEY | FOREIGN KEY (campaign_id) REFERENCES email_campaigns(id) ON DELETE CASCADE |
| email_events_member_id_fkey | FOREIGN KEY | FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE SET NULL |
| email_events_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| fk_email_events_org | FOREIGN KEY | FOREIGN KEY (org_id) REFERENCES organizations(id) |
Indexes
Section titled “Indexes”| Name | Definition |
|---|---|
| email_events_pkey | CREATE UNIQUE INDEX email_events_pkey ON public.email_events USING btree (id) |
| idx_email_events_campaign_id | CREATE INDEX idx_email_events_campaign_id ON public.email_events USING btree (campaign_id) WHERE (campaign_id IS NOT NULL) |
| idx_email_events_created | CREATE INDEX idx_email_events_created ON public.email_events USING btree (created_at DESC) |
| idx_email_events_org_created | CREATE INDEX idx_email_events_org_created ON public.email_events USING btree (org_id, created_at) |
Triggers
Section titled “Triggers”| Name | Definition |
|---|---|
| trg_email_campaign_counts_iud | CREATE TRIGGER trg_email_campaign_counts_iud AFTER INSERT OR DELETE ON public.email_events FOR EACH ROW EXECUTE FUNCTION tg_refresh_email_campaign_counts() |
| trg_email_campaign_counts_update | CREATE TRIGGER trg_email_campaign_counts_update AFTER UPDATE ON public.email_events FOR EACH ROW WHEN (((old.campaign_id IS DISTINCT FROM new.campaign_id) OR (old.event_type IS DISTINCT FROM new.event_type))) EXECUTE FUNCTION tg_refresh_email_campaign_counts() |
Relations
Section titled “Relations”erDiagram
"public.email_events" }o--o| "public.email_campaigns" : "FOREIGN KEY (campaign_id) REFERENCES email_campaigns(id) ON DELETE CASCADE"
"public.email_events" }o--o| "public.members" : "FOREIGN KEY (member_id) REFERENCES members(id) ON DELETE SET NULL"
"public.email_events" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id)"
"public.email_events" {
uuid campaign_id FK ""
uuid member_id FK ""
text org_id FK ""
}
"public.email_campaigns" {
uuid event_id FK "When set, send-campaign resolves recipients from this event's registrants (#4293). ON DELETE RESTRICT (#4408): the audience intent lives only in this column, so the event delete must fail rather than silently widen the campaign to the whole org."
uuid id ""
text org_id FK ""
uuid segment_id FK "When set, recipients are the members matching this segment. ON DELETE RESTRICT (#4408): same reason as event_id — nulling it would silently widen the campaign to the whole org."
uuid template_id FK ""
}
"public.members" {
uuid company_id FK ""
uuid contact_id FK ""
uuid id ""
text org_id FK ""
}
"public.organizations" {
text association_id FK ""
uuid default_approval_reviewer_contact_id FK "Org-level fallback reviewer for two-step send (#5698). Routing chain: the sender's own reviewer, then this, then all org admins. NULL means fall through to the admins, which is the pre-#5698 behaviour."
text id ""
text parent_org_id FK "#671 self-referencing hierarchy pointer. NULL = root org. Direct writes are blocked by trg_block_direct_parent_org_id_writes for every role except service_role/postgres/supabase_admin — the only write path for authenticated/interactive callers is public.reparent_organization(). Cycle-prevented by trg_prevent_org_hierarchy_cycle. #quot;Is association#quot; is derived (EXISTS a child), never stored."
}
Generated by tbls

