public.member_benefit_usage
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”Draw-down ledger against member_entitlements (chamber member benefits) — Not: benefit_usage — that one draws against the legacy/sponsorship entitlements table
Columns
Section titled “Columns”| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| created_at | timestamp with time zone | now() | false | |||
| id | uuid | gen_random_uuid() | false | |||
| member_entitlement_id | uuid | false | public.member_entitlements | |||
| notes | text | true | ||||
| org_id | text | ‘’::text | false | organizations |
||
| quantity | integer | 1 | false | |||
| usage_date | date | CURRENT_DATE | false |
Viewpoints
Section titled “Viewpoints”| Name | Definition |
|---|---|
| Membership & Billing | Members split-payload (members + member_profiles + member_billing + member_metrics), tiers, commerce/billable offers, billing agreements/subscriptions/transactions. Catalog §2.1–2.2, 2.4. Strong first-review cluster for Nathan/Craig. NAMING TRAP — “entitlement” is three different concepts (see docs/db/erd-table-labels.yml): commerce_entitlements = plan/agreement commercial limits; member_entitlements = chamber member benefit allocations; member_product_entitlements = external product provisioning (e.g. Bullseye). The bare entitlements table is NOT the commerce ledger (ADR #2581). |
Constraints
Section titled “Constraints”| Name | Type | Definition |
|---|---|---|
| fk_member_benefit_usage_org | FOREIGN KEY | FOREIGN KEY (org_id) REFERENCES organizations(id) |
| member_benefit_usage_member_entitlement_id_fkey | FOREIGN KEY | FOREIGN KEY (member_entitlement_id) REFERENCES member_entitlements(id) ON DELETE CASCADE |
| member_benefit_usage_pkey | PRIMARY KEY | PRIMARY KEY (id) |
Indexes
Section titled “Indexes”| Name | Definition |
|---|---|
| member_benefit_usage_pkey | CREATE UNIQUE INDEX member_benefit_usage_pkey ON public.member_benefit_usage USING btree (id) |
Triggers
Section titled “Triggers”| Name | Definition |
|---|---|
| on_member_benefit_usage | CREATE TRIGGER on_member_benefit_usage AFTER INSERT ON public.member_benefit_usage FOR EACH ROW EXECUTE FUNCTION trigger_value_event_on_member_benefit_usage() |
Relations
Section titled “Relations”erDiagram
"public.member_benefit_usage" }o--|| "public.member_entitlements" : "FOREIGN KEY (member_entitlement_id) REFERENCES member_entitlements(id) ON DELETE CASCADE"
"public.member_benefit_usage" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id)"
"public.member_benefit_usage" {
uuid member_entitlement_id FK ""
text org_id FK ""
}
"public.member_entitlements" {
uuid benefit_definition_id FK ""
uuid id ""
uuid member_id FK ""
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

