Appearance
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 Name | Description | Data Type | Default Value | Required (= Nullable) | Unique | Format | Validations | Index | Example |
|---|---|---|---|---|---|---|---|---|---|
| id | Primary key of the entity. | UUID | Generated in code (app layer) | Yes | Yes | UUID v7 | - | Primary Key | 019247a1-6d4f-7e21-9b3c-2a5d7f9e0b12 |
| tenantId | Tenant the link belongs to. | UUID | - | Yes | No | UUID v7 | Equal to the tenantId of the entry and of the document. | name: idx_reading_entry_document_tenant_id, type: btree | 018f6e2a-1b2c-7d3e-9f40-5a6b7c8d9e0f |
| readingEntryId | The reading the document supports. | UUID | - | Yes | Part of composite unique | UUID v7 | Foreign Key (readingEntry). | name: uq_reading_entry_document_entry_document, type: btree (unique, partial) | 019247a1-5c3e-7d10-8a2b-1f4c6e8d9a01 |
| documentId | The supporting document. | UUID | - | Yes | Part of composite unique | UUID v7 | Foreign Key (document, Document Management). The document must not be deleted. | name: idx_reading_entry_document_document_id, type: btree | 019247a0-9e1d-7c3b-8f2a-4d6e8a0c2e34 |
| createdAt | Timestamp of record creation. | Timestamp with time zone | now() — set in code | Yes | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | Cannot be null. | - | 2026-05-04T09:52:03.000Z |
| updatedAt | Timestamp of the last update. | Timestamp with time zone | now() — set in code | Yes | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | Cannot be null. | - | 2026-05-04T09:52:03.000Z |
| deletedAt | Soft-delete marker, set when the document is detached from the reading. The document itself is untouched. | Timestamp with time zone | null | No | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | Immutable once set. Active rows: WHERE deletedAt IS NULL. | - | null |
| createdBy | Actor who created the record. | String | - | Yes | No | type:actor | Non-empty. | - | user:018ed0b3-… |
| updatedBy | Actor who last updated the record. | String | - | Yes | No | type:actor | Non-empty. | - | user:018ed0b3-… |
Indexes
| Name | Columns | Type | Why |
|---|---|---|---|
uq_reading_entry_document_entry_document | readingEntryId, documentId where deletedAt is null | Unique, partial | A document is attached to a reading at most once. |
idx_reading_entry_document_document_id | documentId | btree | Answers "which readings use this document" before a document is deleted. |
idx_reading_entry_document_tenant_id | tenantId | btree | Tenant 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.