2.3 KiB
2.3 KiB
Data Model And Migration Boundaries
Naming Model
- Internal canonical naming uses
MachineandPart. - API/UI compatibility keeps
assetandcomponentterminology where already exposed. - In domain aliases:
type Asset = Machinetype Component = Part
Core Persistence Areas
- Asset registry:
machines - Component registry:
parts - Installations:
installations - Observations:
observations - Timeline:
timeline_events - Failures:
failure_events - Asset firmware state:
machine_firmware_states - Component history (canonical):
component_change_events,component_state_snapshots - Asset history (canonical):
asset_change_events,asset_state_snapshots - History jobs/audit:
history_recompute_jobs,history_admin_audit
Out of active model:
projectsis legacy and not used by runtime handlers/contracts.
Migration Policy
- Migrations are stored in
migrations/. - Schema migrations are applied at startup.
- Legacy entities removed in migration
0016_remove_legacy_featuresremain out of active scope. - History architecture was introduced in migration
0017_history_core.
Canonical State Model (History-First)
partsandmachinesare current-state projections optimized for reads.component_change_events/asset_change_eventsare canonical state-change logs.component_state_snapshots/asset_state_snapshotsstore full after-state snapshots for each state-changing event.timeline_events,installations,failure_events, andmachine_firmware_statesare projections and may be rebuilt from history.
History Event Storage Rules
- History events are versioned per entity (
versionis monotonic per component/asset). - State-changing writes persist:
- change event
- after-state snapshot
- projection updates (
parts/machinesand related projections) - timeline projection rows
- History event deletion is soft-delete (
is_deleted) for normal user/admin flow. - Hard restore is destructive for future history rows and is audited in
history_admin_audit.
Timeline Projection Linkage
timeline_events includes logical linkage back to history:
logical_entity_typelogical_event_idcorrelation_idis_deleted
This linkage is required for recompute, rollback/delete propagation, and paired asset/component timeline rendering.