Skip to content

public.org_partnerships

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

Peer org<->org partnership — invite/accept/pause/revoke lifecycle; one LIVE row per pair (pending/active/paused), revoked is terminal, expired can still be revoked — Not: The association/hierarchy subsystem; this is a direct, independent relationship between two orgs

Name Type Default Nullable Children Parents Comment
accepted_at timestamp with time zone true
accepted_by_user_id uuid true
created_at timestamp with time zone now() false
expires_at timestamp with time zone true
id uuid gen_random_uuid() false public.partnership_grants
initiated_by_org_id text false organizations
initiated_by_user_id uuid false
org_a_id text false organizations
org_b_id text false organizations
paused_at timestamp with time zone true
revoke_reason text true
revoked_at timestamp with time zone true
revoked_by_user_id uuid true
status text ‘pending’::text false
updated_at timestamp with time zone now() false
Name Definition
Website, Funnels & Public Surface Website builder config/pages, funnels, blog, public lead capture, member
benefits (hot_deals, job_postings), exchange visibility layer. Catalog §3.5–3.7, §5.1.
Name Type Definition
org_partnerships_accepted_by_user_id_fkey FOREIGN KEY FOREIGN KEY (accepted_by_user_id) REFERENCES auth.users(id)
org_partnerships_canonical_order_check CHECK CHECK ((org_a_id < (org_b_id COLLATE “C”)))
org_partnerships_distinct_pair_check CHECK CHECK ((org_a_id <> org_b_id))
org_partnerships_initiated_by_org_id_fkey FOREIGN KEY FOREIGN KEY (initiated_by_org_id) REFERENCES organizations(id)
org_partnerships_initiated_by_user_id_fkey FOREIGN KEY FOREIGN KEY (initiated_by_user_id) REFERENCES auth.users(id)
org_partnerships_initiator_is_party_check CHECK CHECK (((initiated_by_org_id = org_a_id) OR (initiated_by_org_id = org_b_id)))
org_partnerships_org_a_id_fkey FOREIGN KEY FOREIGN KEY (org_a_id) REFERENCES organizations(id)
org_partnerships_org_b_id_fkey FOREIGN KEY FOREIGN KEY (org_b_id) REFERENCES organizations(id)
org_partnerships_pkey PRIMARY KEY PRIMARY KEY (id)
org_partnerships_revoked_by_user_id_fkey FOREIGN KEY FOREIGN KEY (revoked_by_user_id) REFERENCES auth.users(id)
org_partnerships_status_check CHECK CHECK ((status = ANY (ARRAY[‘pending’::text, ‘active’::text, ‘paused’::text, ‘revoked’::text, ‘expired’::text])))
Name Definition
idx_org_partnerships_org_a CREATE INDEX idx_org_partnerships_org_a ON public.org_partnerships USING btree (org_a_id)
idx_org_partnerships_org_b CREATE INDEX idx_org_partnerships_org_b ON public.org_partnerships USING btree (org_b_id)
org_partnerships_active_pair_uidx CREATE UNIQUE INDEX org_partnerships_active_pair_uidx ON public.org_partnerships USING btree (org_a_id, org_b_id) WHERE (status = ANY (ARRAY[‘pending’::text, ‘active’::text, ‘paused’::text]))
org_partnerships_pkey CREATE UNIQUE INDEX org_partnerships_pkey ON public.org_partnerships USING btree (id)
Name Definition
trg_org_partnerships_updated_at CREATE TRIGGER trg_org_partnerships_updated_at BEFORE UPDATE ON public.org_partnerships FOR EACH ROW EXECUTE FUNCTION update_updated_at_column()
erDiagram

"public.partnership_grants" }o--|| "public.org_partnerships" : "FOREIGN KEY (partnership_id) REFERENCES org_partnerships(id) ON DELETE CASCADE"
"public.org_partnerships" }o--|| "public.organizations" : "FOREIGN KEY (initiated_by_org_id) REFERENCES organizations(id)"
"public.org_partnerships" }o--|| "public.organizations" : "FOREIGN KEY (org_a_id) REFERENCES organizations(id)"
"public.org_partnerships" }o--|| "public.organizations" : "FOREIGN KEY (org_b_id) REFERENCES organizations(id)"

"public.org_partnerships" {
  uuid id ""
  text initiated_by_org_id FK ""
  text org_a_id FK ""
  text org_b_id FK ""
}
"public.partnership_grants" {
  text granting_org_id FK ""
  uuid partnership_id FK ""
  text receiving_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