Appearance
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 Name | Description | Data Type | Default Value | Required (= Nullable) | Unique | Format | Validations | Index | Example |
|---|---|---|---|---|---|---|---|---|---|
| id | Primary key of the entity. | UUID | uuidv7() — DB default | Yes | Yes | UUID v7 | - | Primary Key | 018fa51f-fda1-79f4-8461-2cb8f1cabc10 |
| tenantId | Tenant this record belongs to. | UUID | - | Yes | No | UUID v7 | Foreign Key → tenant; must exist | - | 018fa51f-fda3-7c63-b5a9-3fa33dc989de |
| code | Tenant-unique business key for the sector. | String | - | Yes | No | - | Non-empty | UNIQUE (tenantId, code) | education |
| name | Display name of the sector. | String | - | Yes | No | - | Non-empty | - | Školství |
| color | Display 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, nullable | null | No | No | - | - | - | #4A90D9 |
| legacyId | Legacy-system identifier; the idempotency key the migration CLI's upserts key on. | String, nullable | null | No | No | - | - | UNIQUE (tenantId, legacyId) WHERE legacyId IS NOT NULL | 4821 |
| createdAt | Timestamp of entity creation. Immutable. | Timestamp with time zone | now() | Yes | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | - | - | 2026-03-01T09:00:00Z |
| updatedAt | Timestamp of last update. | Timestamp with time zone | now() | Yes | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | - | - | 2026-03-01T09:00:00Z |
| createdBy | Actor who created this record. | String | - | Yes | No | type:actor | - | - | system:tenant-provisioning |
| updatedBy | Actor who last updated this record. | String | - | Yes | No | type:actor | - | - | system:migration-em3-36 |
| deletedAt | Timestamp 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, nullable | null | No | No | ISO 8601 — YYYY-MM-DDTHH:mm:ss.SSSZ | Active records: WHERE deletedAt IS NULL | name: 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.