ores.iam.tenant
Table of Contents
Core entity for multi-tenancy support. Each tenant represents an isolated organisation with its own users, roles, and data. The system tenant is a special tenant used for shared reference data and system administration; its id is the maximum UUID value (ffffffff-ffff-ffff-ffff-ffffffffffff).
Tenants are identified by:
- id: UUID primary key (SQL also has tenant_id = id for self-reference)
- code: Unique text code for stable referencing (e.g., 'system', 'acme')
- hostname: Unique hostname for tenant routing during login
1. Flags
:system_tenant_visible: is stated because a tenant row is stored under the
system tenant, not under itself: every row of this table carries
tenant_id = ffffffff-ffff-ffff-ffff-ffffffffffff. Without the flag every read
is filtered to tenant_id = <the caller's tenant>, which no row of this table
satisfies, so a tenant can be listed but never read by key – and a read by key
is what a history request, a delete and a single-record read all do.
It is not a widening of what a caller may see. The row that filter excluded is the caller's own tenant, and a tenant admin is the one person who should see it.
2. Columns
2.1. id
UUID uniquely identifying this tenant.
The system tenant has the maximum UUID value, ffffffff-ffff-ffff-ffff-ffffffffffff. In SQL, tenant_id = id for tenant records.
2.2. code
Unique code for stable referencing.
Examples: 'system', 'acme', 'demo'.
std::string(faker::word::noun()) + "_tenant"
2.3. name
Human-readable display name for the tenant.
std::string(faker::company::companyName())
2.4. type
Tenant type classification (FK to tenant_types). The synthetic generator emits the canonical automation type: the type/status insert validations reject any value with no active tenant_type row, and the seed data (iam_tenant_types_populate.sql) seeds the four system-tenant types, of which automation is the system-process default.
"automation"
2.5. description
Detailed description of the tenant.
std::string(faker::lorem::sentence())
2.6. hostname
Unique hostname for tenant routing.
std::string(faker::word::noun()) + ".example.com"
2.7. status
Tenant lifecycle status (FK to tenant_statuses).
"active"
3. SQL
3.1. Flags
3.2. Checks
| expression |
|---|
| "id" <> 'ffffffff-ffff-ffff-ffff-ffffffffffff'::uuid or "code" = 'system' |
| "tenant_id" = ores_utility_system_tenant_id_fn() |
| "code" <> '' |
| "hostname" <> '' |
3.3. Delete sets
| expression |
|---|
| status = 'terminated' |
4. Insert trigger
4.1. Validations
| column | validation_function |
|---|---|
| type | ores_iam_validate_tenant_type_fn |
| status | ores_iam_validate_tenant_status_fn |
5. C++
5.1. Flags
5.2. Repository
5.3. Domain includes
#include <chrono> #include <string> #include <optional> #include <boost/uuid/uuid.hpp>
5.4. Entity includes
#include <string> #include "sqlgen/Timestamp.hpp" #include "sqlgen/PrimaryKey.hpp"
5.5. Conventions
5.6. Table display
| column | header |
|---|---|
| code | Code |
| name | Name |
| type | Type |
| hostname | Hostname |
| status | Status |
| modified_by | Modified By |
| version | Version |
5.7. Presentation
5.7.1. Detail fields
| field | label | widget | type | is_key | is_required | placeholder |
|---|---|---|---|---|---|---|
| code | Code | codeEdit | line_edit | true | true | Enter tenant code |
| name | Name | nameEdit | line_edit | true | Enter display name | |
| type | Type | typeEdit | line_edit | Enter tenant type | ||
| hostname | Hostname | hostnameEdit | line_edit | Enter hostname | ||
| status | Status | statusEdit | line_edit | Enter status |
5.7.2. Columns
| enum_name | field | header | type | width |
|---|---|---|---|---|
| Code | code | Code | string | 120 |
| Name | name | Name | string | 200 |
| Type | type | Type | string | 100 |
| Hostname | hostname | Hostname | string | 180 |
| Status | status | Status | string | 100 |
| Version | version | Version | int | 80 |
| ModifiedBy | modified_by | Modified By | string | 120 |
| RecordedAt | recorded_at | Recorded At | timestamp | 150 |
5.8. Custom repository methods
6. See also
- ores.iam — component group overview.