Skip to main content
CompanyEmail is a soft-deletable pivot (bridge) entity that links a Company to an Email address within the same workspace. Each row carries three metadata flags — is_primary, is_verify, and label — that characterize how the email relates to its parent company. The entity enforces a partial-unique constraint: at most one non-deleted row per company can carry is_primary = TRUE, preventing multiple primary emails on the same company. It has no public UUID of its own; it is accessed via the parent company’s relationship graph, not as a first-class API resource.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • created_at — set once by MikroORM onCreate: () => new Date(); never updated afterward (note: no updated_at column on this entity).
  • deleted_at — written by soft-delete cascades when the parent Company is soft-deleted; also written by service-layer cleanup when an Email association is explicitly removed.
  • Partial-unique index uniq_company_emails_primary_company is maintained by the database engine; enforcement is automatic on INSERT/UPDATE WHERE deleted_at IS NULL AND is_primary IS TRUE.
  • The entity has no public UUID (*_id column). It is not directly addressable via the public API; access is always through the parent company’s array relationship (e.g. company_emails on the Company resource).
  • Provenance (source_workspace_connector_pk) is not tracked on this entity; rows are written by the enrichment pipeline, connector sync (via reconciliation persister), and direct service-layer mutations — the source is inferred from the parent Company’s sourceWorkspaceConnector if needed.

Example

Source: apps/api/src/database/entities/CompanyEmail.ts · domain: financial-graph · tier: Supporting