Asset Storage
Summary
Source-backed persistence of the canonical Asset aggregate root — its scalar columns, owned value objects, lifecycle state, generated values, and current integrity gaps.
Audience
Backend engineers, database reviewers, architects, QA, support, operations, security reviewers, and product owners.
Overview
Asset is the aggregate root of the Asset bounded context and maps to the Assets table. It carries the tenant scope, a compatibility identity, four owned value objects, free-text category, lifecycle status and condition, an optional assignee, workflow linkage, and creation/update evidence. Assignment history and document references are owned children (documented separately) that cascade from the same table's key.
Confirmed persistence behavior
| Field | Storage | Required | Notes |
|---|---|---|---|
| Id | Guid primary key | Yes | Assigned by the aggregate factory (not a DB default at runtime) |
| TenantId | integer | Yes | Tenant scope; participates in query filter and composite indexes |
| TenantKey | varchar(120) | No | Optional tenant slug |
| CompatId | integer identity | Yes | Numeric external id; unique index; DB identity at runtime, app-assigned during backfill |
| Code | owned AssetCode → AssetCode varchar(80) | Yes | Upper-cased; non-unique lookup index |
| AssetType | varchar(120) | Yes | Free-text category, default General, normalized and length-checked |
| Name | owned AssetName → AssetName varchar(200) | Yes | Display name |
| Serial | owned SerialNumber → SerialNumber varchar(160) | Yes at DB | Empty string allowed for requests/consumables |
| Assignee | owned AssetAssignee → AssignedToUserId, LaborId | No | Both integer, nullable; identifier-only references |
| AssignedOnUtc | timestamptz | No | Set on issue, cleared on return/available |
| ReturnDueDate | timestamp without time zone | No | Date-only |
| Condition | AssetCondition enum → varchar(40) | Yes | Default New |
| Status | AssetStatus enum → varchar(40) | Yes | Default Available |
| Notes | varchar(2000) | No | Free text |
| WorkflowInstanceId | Guid | No | Set when approval is delegated to the Workflow Service |
| CreatedOnUtc / UpdatedOnUtc | timestamptz | Yes | Lifecycle evidence |
- Owned value objects persist as columns on the same row:
AssetCode,AssetName,SerialNumber, and the assignee pairAssignedToUserId/LaborId. See Value-Object Conversions. - Enums
AssetStatus(Available, Requested, Approved, Issued, Rejected, Returned, Damaged, Lost, Repair, Retired) andAssetCondition(New, Good, Repair, Damaged, Lost) are stored as strings, not integers. - Ignored domain property:
DomainEventsis not mapped (Ignore). Computed properties (IsWorkflowManaged,IsDeletable) are not persisted. - Generated values:
CompatIduses a database identity column at runtime;Idis a Guid supplied by the factory. - Lifecycle storage: status transitions mutate
Status/Condition/Assigneein place and stampUpdatedOnUtc; each transition also appends an assignment-history row. - Duplicate prevention: per-tenant asset-code uniqueness is enforced in the application layer (
CodeExistsAsyncover the tenant-filtered query). TheAssetCodeindex is non-unique; there is no database unique constraint on the code.
Integrity gaps
- No database uniqueness on
AssetCode(application-enforced only) or onSerialNumber(none at all). AssignedToUserId,LaborId, andWorkflowInstanceIdare identifier-only values with no foreign keys.- No concurrency token protects concurrent lifecycle transitions. See Concurrency.
Classification
Implemented aggregate persistence with Transitional compatibility identity.
Requires confirmation
Per-tenant code-uniqueness hardening, serial-number policy, and concurrency protection require confirmation.
Diagram
Related Articles
See Also
Keywords
- Asset persistence
- Asset Storage
- Draft database documentation
Source References
microservices/src/asset-service/Domain/Asset/Asset.csmicroservices/src/asset-service/Infrastructure/AssetDbContext.csmicroservices/src/asset-service/Domain/Common/Enums.csmicroservices/src/asset-service/Infrastructure/Migrations/AssetDbContextModelSnapshot.cs
Revision Information
- Status: Draft
- Last reviewed: 2026-07-17
- Review cycle: Quarterly