Skip to content
Updated Sep 29, 2026 by Pablo Coufal · Owner: analysisactiveentity Edit on GitHub

Entity: readingEntryDocument ​

Entity Type: Database table (tenant schema)

Description: Links a manual reading (readingEntry) to a document kept in Document Management — typically a photo or scan of the meter proving the value. The file itself, its storage, type checks and metadata belong to the document; this row only says that the document supports this reading. A document can support several readings, and a reading can have several documents.

A link, not a copy. Attaching "from documents" picks an existing document; attaching "from computer" first stores the file as a new document and then links it. Either way the document appears in the building's documents, and removing the link does not remove the document.

Data Attributes Table ​

Attribute NameDescriptionData TypeDefault ValueRequired (= Nullable)UniqueFormatValidationsIndexExample
idPrimary key of the entity.UUIDGenerated in code (app layer)YesYesUUID v7-Primary Key019247a1-6d4f-7e21-9b3c-2a5d7f9e0b12
tenantIdTenant the link belongs to.UUID-YesNoUUID v7Equal to the tenantId of the entry and of the document.name: idx_reading_entry_document_tenant_id, type: btree018f6e2a-1b2c-7d3e-9f40-5a6b7c8d9e0f
readingEntryIdThe reading the document supports.UUID-YesPart of composite uniqueUUID v7Foreign Key (readingEntry).name: uq_reading_entry_document_entry_document, type: btree (unique, partial)019247a1-5c3e-7d10-8a2b-1f4c6e8d9a01
documentIdThe supporting document.UUID-YesPart of composite uniqueUUID v7Foreign Key (document, Document Management). The document must not be deleted.name: idx_reading_entry_document_document_id, type: btree019247a0-9e1d-7c3b-8f2a-4d6e8a0c2e34
createdAtTimestamp of record creation.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null.-2026-05-04T09:52:03.000Z
updatedAtTimestamp of the last update.Timestamp with time zonenow() — set in codeYesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZCannot be null.-2026-05-04T09:52:03.000Z
deletedAtSoft-delete marker, set when the document is detached from the reading. The document itself is untouched.Timestamp with time zonenullNoNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZImmutable once set. Active rows: WHERE deletedAt IS NULL.-null
createdByActor who created the record.String-YesNotype:actorNon-empty.-user:018ed0b3-…
updatedByActor who last updated the record.String-YesNotype:actorNon-empty.-user:018ed0b3-…

Indexes ​

NameColumnsTypeWhy
uq_reading_entry_document_entry_documentreadingEntryId, documentId where deletedAt is nullUnique, partialA document is attached to a reading at most once.
idx_reading_entry_document_document_iddocumentIdbtreeAnswers "which readings use this document" before a document is deleted.
idx_reading_entry_document_tenant_idtenantIdbtreeTenant predicate on every read.

Audited fields ​

Recorded on created (in full) and deleted (in full): readingEntryId, documentId. The row changes only when the document is detached.

Excluded: tenantId — fixed by the request context, so it carries no information about the change.