public.entitlements
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”Legacy / sponsorship-fulfilment entitlement rows (not the platform commerce ledger) — Not: commerce_entitlements (ADR 2581 explicitly distinguishes these) — See: docs/decisions/2581-modules-vs-entitlements-vs-rls.md
Columns
Section titled “Columns”| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| allocated_quantity | integer | 0 | false | |||
| benefit_definition_id | uuid | false | public.benefit_definitions | |||
| company_id | uuid | false | companies |
|||
| created_at | timestamp with time zone | now() | false | |||
| expires_at | date | true | ||||
| id | uuid | gen_random_uuid() | false | benefit_reservations benefit_usage |
||
| membership_unit_id | uuid | true | membership_units |
|||
| org_id | text | ‘’::text | false | organizations |
||
| reserved_quantity | integer | 0 | false | |||
| sponsor_subscription_id | uuid | false | sponsorships |
|||
| start_date | date | CURRENT_DATE | false | |||
| status | text | ‘active’::text | false | |||
| updated_at | timestamp with time zone | now() | false | |||
| used_quantity | integer | 0 | 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 |
|---|---|---|
| entitlements_benefit_definition_id_fkey | FOREIGN KEY | FOREIGN KEY (benefit_definition_id) REFERENCES benefit_definitions(id) ON DELETE RESTRICT |
| entitlements_company_id_fkey | FOREIGN KEY | FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE |
| entitlements_membership_unit_id_fkey | FOREIGN KEY | FOREIGN KEY (membership_unit_id) REFERENCES membership_units(id) ON DELETE SET NULL |
| entitlements_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| entitlements_sponsor_subscription_id_fkey | FOREIGN KEY | FOREIGN KEY (sponsor_subscription_id) REFERENCES sponsorships(id) ON DELETE CASCADE |
| fk_entitlements_org | FOREIGN KEY | FOREIGN KEY (org_id) REFERENCES organizations(id) |
Indexes
Section titled “Indexes”| Name | Definition |
|---|---|
| entitlements_pkey | CREATE UNIQUE INDEX entitlements_pkey ON public.entitlements USING btree (id) |
Triggers
Section titled “Triggers”| Name | Definition |
|---|---|
| entitlements_updated_at | CREATE TRIGGER entitlements_updated_at BEFORE UPDATE ON public.entitlements FOR EACH ROW EXECUTE FUNCTION update_updated_at_column() |
Relations
Section titled “Relations”erDiagram
"public.entitlements" }o--|| "public.benefit_definitions" : "FOREIGN KEY (benefit_definition_id) REFERENCES benefit_definitions(id) ON DELETE RESTRICT"
"public.entitlements" }o--|| "public.companies" : "FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE"
"public.benefit_reservations" }o--|| "public.entitlements" : "FOREIGN KEY (entitlement_id) REFERENCES entitlements(id) ON DELETE CASCADE"
"public.benefit_usage" }o--|| "public.entitlements" : "FOREIGN KEY (entitlement_id) REFERENCES entitlements(id) ON DELETE CASCADE"
"public.entitlements" }o--o| "public.membership_units" : "FOREIGN KEY (membership_unit_id) REFERENCES membership_units(id) ON DELETE SET NULL"
"public.entitlements" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id)"
"public.entitlements" }o--|| "public.sponsorships" : "FOREIGN KEY (sponsor_subscription_id) REFERENCES sponsorships(id) ON DELETE CASCADE"
"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.benefit_definitions" {
uuid id ""
text org_id FK ""
}
"public.companies" {
uuid id ""
text org_id FK ""
uuid primary_contact_id FK ""
}
"public.benefit_reservations" {
uuid entitlement_id FK ""
uuid id ""
text org_id FK ""
}
"public.benefit_usage" {
uuid entitlement_id FK ""
text org_id FK ""
uuid reservation_id FK ""
}
"public.membership_units" {
uuid company_id FK ""
uuid id ""
text org_id FK ""
uuid owner_member_id FK ""
}
"public.organizations" {
text association_id FK ""
text id ""
}
"public.sponsorships" {
uuid company_id FK ""
uuid event_id FK "#3542: set for an event-scoped sponsorship; NULL for an org-level one."
uuid id ""
uuid member_id FK ""
uuid membership_unit_id FK ""
uuid offering_id FK "#3542: FK to sponsorship_offerings (renamed from tier_id)."
text org_id FK ""
uuid signature_event_id FK ""
uuid subscription_id FK ""
}
Generated by tbls

