#nullable enable using System; using System.Collections.Generic; using System.Text.Json.Serialization; namespace LANCommander.SDK.Migrations; /// /// Represents the outcome of a migration execution attempt. /// [JsonConverter(typeof(JsonStringEnumConverter))] public enum MigrationStatus { /// /// Migration executed successfully. /// Executed, /// /// Migration was skipped because ShouldExecuteAsync returned false. /// SkippedNotApplicable, /// /// Migration was skipped because it was already executed previously. /// SkippedAlreadyExecuted, /// /// Migration was skipped because pre-checks failed. /// SkippedPreChecksFailed, /// /// Migration failed during execution. /// Failed } /// /// Represents a single migration history entry with metadata about the execution. /// public class MigrationHistoryEntry { /// /// The fully qualified type name of the migration. /// public string MigrationName { get; set; } = string.Empty; /// /// The version of the migration. /// public string Version { get; set; } = string.Empty; /// /// The outcome of the migration attempt. /// public MigrationStatus Status { get; set; } /// /// When the migration was attempted. /// public DateTimeOffset ExecutedAt { get; set; } /// /// How long the migration took to execute (in milliseconds). /// public long DurationMs { get; set; } /// /// Whether ShouldExecuteAsync returned true. /// public bool ShouldExecute { get; set; } /// /// Whether PerformPreChecksAsync returned true (null if not evaluated). /// public bool? PreChecksPassed { get; set; } /// /// Error message if the migration failed. /// public string? ErrorMessage { get; set; } /// /// Stack trace if the migration failed. /// public string? StackTrace { get; set; } /// /// The application version that ran this migration. /// public string? ApplicationVersion { get; set; } /// /// The name of the application that ran this migration. /// public string? Application { get; set; } /// /// The machine name where the migration was executed. /// public string? MachineName { get; set; } } /// /// Represents the complete migration history for the application. /// public class MigrationHistory { /// /// Schema version for the migration history file format. /// public int SchemaVersion { get; set; } = 1; /// /// When this history file was last updated. /// public DateTimeOffset LastUpdated { get; set; } /// /// Collection of all migration history entries. /// public List Entries { get; set; } = new(); }