Skip to content
Updated Sep 26, 2026 by Barča Dvořáková · Owner: analysisactiveentityconfluence-migration Edit on GitHub

Entity: contract ​

Entity: contract

Description: An energy supply contract covering one or more gauges (via contractGauge), typically representing a joint/bulk purchase agreement negotiated centrally for a group of metering points, but equally valid for a single metering point with its own individual contract (N=1 is the common case — see the Migration Notes on the source Confluence page, id 523993090). Carries the supplier and unit prices for the contract's validity period; individual price components are stored on contractItem.

Entity Type: database table

Data Attributes Table ​

Attribute NameDescriptionData TypeDefault ValueRequired (= Nullable)UniqueFormatValidationsIndexExample
idPrimary key of the entity.UUIDGenerated in code (app layer)YesYesUUID v7-Primary Key018ed0b3-c298-7c7a-96d5-8b36f5a7f8d2
tenantIdTenant this record belongs to.UUID-YesNoUUID v7Foreign Key: tenant; must exist-018fa51f-fda1-79f4-8461-2cb8f1cabc10
mediumCommodity this contract covers.string (enum)-YesNoenum — see Medium (source Confluence page; not yet migrated to the local enum catalog)Must be one of the supported subset values-electricity
purchaseTypeWhether this contract is an individual contract for a single metering point, or a joint/bulk purchase agreement covering a group.string (enum)individualYesNoenum — see ContractPurchaseType (source Confluence page; not yet migrated to the local enum catalog)Must be one of the listed values-individual
supplierIdThe supplier for this contract.UUID-YesNoUUID v7Foreign Key: contractSupplier; must exist-018fa51f-fda3-7c63-b5a9-3fa33dc989de
validFromStart of the contract's validity period.date-YesNoISO 8601 — YYYY-MM-DDMust be ≤ validTo-2026-01-01
validToEnd of the contract's validity period.date-YesNoISO 8601 — YYYY-MM-DDMust be ≥ validFrom. For a given gauge + medium, validity periods of different contracts must not overlap (carried over from EM2 business rule)-2026-12-31
isManualWhether this record was entered manually by a user (true) or created by an automated backfill/migration process (false). Kept for audit traceability of data origin, mirrors EM2's manual flag.booleantrueYesNo---true
documentIdThe uploaded contract document (PDF), if any.UUID-NoNoUUID v7Foreign Key: document; must exist if set-018fa51f-fda4-7e95-88e8-5f5675f0ddf8
createdAtTimestamp of entity creation. Immutable.timestamp with time zonenow()YesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ--2026-01-15T09:00:00Z
updatedAtTimestamp of last entity update. Mutable.timestamp with time zonenow()YesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ--2026-01-15T09:00:00Z
deletedAtTimestamp of entity soft delete. Once set, immutable.timestamp with time zone-NoNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZImmutable once set. Active records: WHERE deletedAt IS NULL-null
createdByIdentifier of the author who created this record.string-YesNotype:actor--user:c2d3f586-1c9a-4f5f-b9ae-45f2c4f69f7e
updatedByIdentifier of the author who last updated this record.string-YesNotype:actor--system:contract-backfill-v1

Audited fields ​

Recorded on created (in full), updated (changed only) and deleted (in full): medium, purchaseType, supplierId, validFrom, validTo, isManual, documentId.

Excluded:

  • validityStatus — computed in SQL on every read from validFrom/validTo, never stored. It can flip from upcoming to active to expired with no write happening at all; auditing it would fabricate entries for the mere passage of time.

supplierName is not a column on this entity at all (it is joined from contractSupplier.name for display) and so is outside this derivation entirely; when supplierId changes, the resolved supplierName at that time is carried alongside it as a display value, not as an audited field of its own.

medium is create-only — absent from the update path entirely, so it never appears in an updated diff, only in a created entry.

Registered for entityName resolution — resolves to the contract's supplier name and validity range (e.g. "Acme Energy (2024-01-01 – 2024-12-31)"), composed at read time from contractSupplier.name and this entity's own validFrom/validTo — not a contract-number attribute, since none exists on this DAT (architecture 61-audit-log.md §7.4 in the code repo).