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

Entity: sector ​

Entity Type: Database table

Description: A tenant-scoped reference/classification codebook for buildings (e.g. školství, úřad), referenced from building.sectorId. Not a child of any one building — many buildings can point at the same sector, sector carries no buildingId, and it has no FK to any other entity; the FK runs the other way. Read-only for end users today: the only inbound HTTP surface is GET /v1/building-sectors; there is no create/update/delete endpoint. Rows are written only by tenant provisioning (seeding one default unclassified / Nezařazeno sector per new tenant) and by the legacy migration CLI.

Data Attributes Table ​

Attribute NameDescriptionData TypeDefault ValueRequired (= Nullable)UniqueFormatValidationsIndexExample
idPrimary key of the entity.UUIDuuidv7() — DB defaultYesYesUUID v7-Primary Key018fa51f-fda1-79f4-8461-2cb8f1cabc10
tenantIdTenant this record belongs to.UUID-YesNoUUID v7Foreign Key → tenant; must exist-018fa51f-fda3-7c63-b5a9-3fa33dc989de
codeTenant-unique business key for the sector.String-YesNo-Non-emptyUNIQUE (tenantId, code)education
nameDisplay name of the sector.String-YesNo-Non-empty-Školství
colorDisplay color, preserved from the legacy system. Not currently reachable through SectorPostgresAdapter.update()'s SQL — set only at creation or by the legacy-migration CLI's own upsert.String, nullablenullNoNo---#4A90D9
legacyIdLegacy-system identifier; the idempotency key the migration CLI's upserts key on.String, nullablenullNoNo--UNIQUE (tenantId, legacyId) WHERE legacyId IS NOT NULL4821
createdAtTimestamp of entity creation. Immutable.Timestamp with time zonenow()YesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ--2026-03-01T09:00:00Z
updatedAtTimestamp of last update.Timestamp with time zonenow()YesNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ--2026-03-01T09:00:00Z
createdByActor who created this record.String-YesNotype:actor--system:tenant-provisioning
updatedByActor who last updated this record.String-YesNotype:actor--system:migration-em3-36
deletedAtTimestamp of soft delete. UNIQUE (tenantId, code) is retained unchanged even for soft-deleted rows — a deleted sector's code stays reserved; reuse is a deferred follow-up.Timestamp with time zone, nullablenullNoNoISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZActive records: WHERE deletedAt IS NULLname: idx_sector_deleted_at, type: btree (partial, WHERE deleted_at IS NULL)null

Audited fields ​

Recorded on created (in full), updated (changed only) and deleted (in full): code, name, color, legacyId.

Excluded: none.

Every entry carries subjectEntityType = null / subjectEntityId = null — sector is the referenced side of a many-to-one relationship (many buildings, one sector), so no single building owns it, and it has no children of its own to self-subject either. Registered for entityName resolution — resolves to name (the sector's display label, e.g. "Školství"), not code (the tenant-unique business key, e.g. "education"), which is a separate attribute not surfaced by this resolution (architecture 61-audit-log.md §7.4 in the code repo). No end-user create/update/delete surface exists — insert/update/delete are reachable only via tenant provisioning and the legacy migration CLI.