Skip to content

public.commerce_entitlements

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

Plan / agreement commercial limits (seats, quota, access windows) — Not: Chamber member benefit allocations (see member_entitlements) — See: docs/decisions/2581-modules-vs-entitlements-vs-rls.md

Name Type Default Nullable Children Parents Comment
beneficiary_id text false
beneficiary_type text false
billing_agreement_id uuid false billing_agreements
created_at timestamp with time zone now() false
entitlement_type text ‘access’::text false
expires_at date true
granted_quantity integer 0 true
id uuid gen_random_uuid() false
metadata_json jsonb ‘{}’::jsonb true
product_id uuid false public.commerce_products
starts_at date CURRENT_DATE false
status text ‘active’::text false
updated_at timestamp with time zone now() false
used_quantity integer 0 false
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).
Name Type Definition
commerce_entitlements_beneficiary_type_check CHECK CHECK ((beneficiary_type = ANY (ARRAY[‘member’::text, ‘membership_unit’::text, ‘organization’::text, ‘association’::text])))
commerce_entitlements_billing_agreement_id_fkey FOREIGN KEY FOREIGN KEY (billing_agreement_id) REFERENCES billing_agreements(id) ON DELETE CASCADE
commerce_entitlements_entitlement_type_check CHECK CHECK ((entitlement_type = ANY (ARRAY[‘access’::text, ‘quota’::text, ‘feature’::text, ‘seats’::text, ‘credits’::text])))
commerce_entitlements_pkey PRIMARY KEY PRIMARY KEY (id)
commerce_entitlements_product_id_fkey FOREIGN KEY FOREIGN KEY (product_id) REFERENCES commerce_products(id) ON DELETE RESTRICT
commerce_entitlements_status_check CHECK CHECK ((status = ANY (ARRAY[‘active’::text, ‘suspended’::text, ‘expired’::text, ‘revoked’::text])))
Name Definition
commerce_entitlements_pkey CREATE UNIQUE INDEX commerce_entitlements_pkey ON public.commerce_entitlements USING btree (id)
idx_commerce_entitlements_agreement CREATE INDEX idx_commerce_entitlements_agreement ON public.commerce_entitlements USING btree (billing_agreement_id)
idx_commerce_entitlements_beneficiary CREATE INDEX idx_commerce_entitlements_beneficiary ON public.commerce_entitlements USING btree (beneficiary_type, beneficiary_id)
Name Definition
commerce_entitlements_updated_at CREATE TRIGGER commerce_entitlements_updated_at BEFORE UPDATE ON public.commerce_entitlements FOR EACH ROW EXECUTE FUNCTION update_updated_at_column()
erDiagram

"public.commerce_entitlements" }o--|| "public.billing_agreements" : "FOREIGN KEY (billing_agreement_id) REFERENCES billing_agreements(id) ON DELETE CASCADE"
"public.commerce_entitlements" }o--|| "public.commerce_products" : "FOREIGN KEY (product_id) REFERENCES commerce_products(id) ON DELETE RESTRICT"

"public.commerce_entitlements" {
  uuid billing_agreement_id FK ""
  uuid product_id FK ""
}
"public.billing_agreements" {
  uuid id ""
  uuid product_id FK ""
}
"public.commerce_products" {
  uuid id ""
}

Generated by tbls