Skip to main content
CompanyMedia is a soft-deleteable pivot (bridge) entity that links a Company to a Media asset. It records when a media file (logo, avatar, or banner) was associated with a company and is the persistence mechanism for the β€œadd/remove company media” mutations. The entity carries no scalar attributes of its own beyond timestamps; all descriptive content lives on the related Media row. Two compound indexes optimise the Hasura array-relationship traversals in both directions: (company_pk, deleted_at) for the forward pass and (media_pk) for the reverse pass.
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 via MikroORM onCreate hook (new Date()); not writable by callers
  • deleted_at β€” written by soft-delete mutations (useAddCompanyMedia / useDeleteCompanyMedia service layer); never set by the user directly via PATCH
  • pk β€” internal auto-increment integer primary key; never exposed in the public API. No public UUID (*_id) column exists on this entity β€” the entity is identified in the API by its relationship context (company_id + media_id pair), not by a standalone resource id
  • Indexes maintained by migrations: idx_company_media_company_deleted (company_pk, deleted_at) β€” hot-path for Hasura forward traversal; idx_company_media_media (media_pk) β€” hot-path for Hasura reverse traversal. Both created in Migration20260416000000_hasura_and_service_hot_path_indexes_round4.

Example

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