Skip to main content
Version: v1.0.0(int)

Contacts

Org-private pool of people, with optional email/phone methods, linkable to entities in the org (customers, vendors, locations).

ER diagram

org.contacts

ColumnTypeNotes
idUUID PK
org_idUUID FKplatform.organizations(id).
display_nameVARCHAR(255)NOT NULL. UI-facing name on the contact card.
first_nameVARCHAR(100)
last_nameVARCHAR(100)
titleVARCHAR(150)
notesTEXT
is_activeBOOLNOT NULL. Default true.
created_atTIMESTAMPTZNOT NULL. Default NOW().
updated_atTIMESTAMPTZNOT NULL. Default NOW(). Auto-updated by trigger.

org.contact_methods

Emails and phones attached to a contact.

ColumnTypeNotes
idUUID PK
org_idUUID FKplatform.organizations(id).
contact_idUUID FKorg.contacts(id) ON DELETE CASCADE.
method_typecontact_method_kindNOT NULL. ENUM (email, phone).
valueVARCHAR(320)NOT NULL. Email address or phone number.
labelVARCHAR(50)e.g. work, mobile, billing.
is_primaryBOOLNOT NULL. Default false.
is_activeBOOLNOT NULL. Default true.
created_atTIMESTAMPTZNOT NULL. Default NOW().
updated_atTIMESTAMPTZNOT NULL. Default NOW(). Auto-updated by trigger.

Constraints:

  • UNIQUE (contact_id, method_type, value).
  • Partial UNIQUE (contact_id, method_type) WHERE is_primary = true — at most one primary email and one primary phone per contact.

org.entity_contacts

Polymorphic link between a contact and an entity. entity_id has no DB-level FK; the application is responsible for cleanup when the parent row is deleted.

ColumnTypeNotes
idUUID PK
org_idUUID FKplatform.organizations(id).
contact_idUUID FKorg.contacts(id) ON DELETE CASCADE.
entity_typeentity_contact_kindNOT NULL. ENUM (customer, vendor, location). Values added later via ALTER TYPE ADD VALUE.
entity_idUUIDNOT NULL. Id of the row in the corresponding entity table. No DB-level FK.
roleVARCHAR(50)e.g. billing, shipping, sales, ops. Nullable.
is_primaryBOOLNOT NULL. Default false.
notesTEXTPer-link notes — distinct from the contact's own notes.
is_activeBOOLNOT NULL. Default true.
created_atTIMESTAMPTZNOT NULL. Default NOW().
updated_atTIMESTAMPTZNOT NULL. Default NOW(). Auto-updated by trigger.

Constraints:

  • UNIQUE (contact_id, entity_type, entity_id, role) — same contact can have multiple roles for the same entity, but not the same role twice.
  • Partial UNIQUE (entity_type, entity_id) WHERE is_primary = true — at most one primary contact per entity.