Sigra.Install.MigrationTimestamps (Sigra v1.20.0)

Copy Markdown View Source

Deterministic slot-based timestamp allocator for installer migrations (GEN-07).

Replaces the old offset_timestamp/1 helper that lived in Mix.Tasks.Sigra.Install before Phase 11, which based timestamps on :calendar.universal_time, making re-runs non-deterministic and cross-feature ordering implicit. The slot allocator:

  1. Walks the canonical feature list in order.
  2. For each feature, iterates migrations/1 slot entries in the order the feature returned them.
  3. Assigns base_time + N seconds where N is a globally incrementing counter across all features.

This means Features.Core's :primary slot always gets an earlier timestamp than Features.Organizations's first slot, regardless of wall-clock time. Cross-feature ordering is static, not timing- dependent.

Idempotent re-run is handled by the walker layer: if a migration file already exists on disk that matches target_basename, the walker reuses its filename instead of allocating a new timestamp.

Summary

Functions

allocate(features, base_time)

@spec allocate(features :: [module()], base_time :: DateTime.t()) :: %{
  required(module()) => %{required(atom()) => String.t()}
}