Skip to content

public.benefit_usage

Synced from docs/generated/erd/ — do not hand-edit.
Regenerate with bun 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

Draw-down ledger against entitlements (legacy / sponsorship fulfilment) — Not: member_benefit_usage — the chamber member benefit ledger

Name Type Default Nullable Children Parents Comment
created_at timestamp with time zone now() false
entitlement_id uuid false public.entitlements
fulfillment_status text ‘fulfilled’::text false
id uuid gen_random_uuid() false
notes text true
org_id text ‘’::text false organizations
quantity integer 1 false
reservation_id uuid true public.benefit_reservations
usage_date date CURRENT_DATE false
used_for_id text true
used_for_type text ‘event’::text false
Name Definition
Sponsorships Sponsorship offerings and bookings, event sponsor slots/fulfillment,
sponsor impressions/placements, package benefits. Catalog §2.3.
(Table names on staging: sponsorships / sponsorship_offerings — not
sponsorship_inventory from older prose.)
Name Type Definition
benefit_usage_entitlement_id_fkey FOREIGN KEY FOREIGN KEY (entitlement_id) REFERENCES entitlements(id) ON DELETE CASCADE
benefit_usage_pkey PRIMARY KEY PRIMARY KEY (id)
benefit_usage_reservation_id_fkey FOREIGN KEY FOREIGN KEY (reservation_id) REFERENCES benefit_reservations(id) ON DELETE SET NULL
fk_benefit_usage_org FOREIGN KEY FOREIGN KEY (org_id) REFERENCES organizations(id)
Name Definition
benefit_usage_pkey CREATE UNIQUE INDEX benefit_usage_pkey ON public.benefit_usage USING btree (id)
Name Definition
trg_value_event_benefit CREATE TRIGGER trg_value_event_benefit AFTER INSERT ON public.benefit_usage FOR EACH ROW EXECUTE FUNCTION trigger_value_event_on_benefit_usage()
erDiagram

"public.benefit_usage" }o--|| "public.entitlements" : "FOREIGN KEY (entitlement_id) REFERENCES entitlements(id) ON DELETE CASCADE"
"public.benefit_usage" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id)"
"public.benefit_usage" }o--o| "public.benefit_reservations" : "FOREIGN KEY (reservation_id) REFERENCES benefit_reservations(id) ON DELETE SET NULL"

"public.benefit_usage" {
  uuid entitlement_id FK ""
  text org_id FK ""
  uuid reservation_id FK ""
}
"public.entitlements" {
  uuid benefit_definition_id FK ""
  uuid company_id FK ""
  uuid id ""
  uuid membership_unit_id FK ""
  text org_id FK ""
  uuid sponsor_subscription_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."
}
"public.benefit_reservations" {
  uuid entitlement_id FK ""
  uuid id ""
  text org_id FK ""
}

Generated by tbls