Adding more info to migration history

This commit is contained in:
Aaron Powell 2025-12-19 16:01:14 +11:00
parent b07ad7d9a9
commit 216f34144b
2 changed files with 19 additions and 0 deletions

View file

@ -92,6 +92,11 @@ public class MigrationHistoryEntry
/// </summary>
public string? ApplicationVersion { get; set; }
/// <summary>
/// The name of the application that ran this migration.
/// </summary>
public string? Application { get; set; }
/// <summary>
/// The machine name where the migration was executed.
/// </summary>

View file

@ -124,6 +124,7 @@ public class MigrationHistoryService(ILogger<MigrationHistoryService> logger)
ErrorMessage = exception?.Message,
StackTrace = exception?.StackTrace,
ApplicationVersion = GetApplicationVersion(),
Application = GetApplicationName(),
MachineName = Environment.MachineName
};
@ -172,4 +173,17 @@ public class MigrationHistoryService(ILogger<MigrationHistoryService> logger)
return null;
}
}
private static string? GetApplicationName()
{
try
{
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
return assembly.GetName().Name;
}
catch
{
return null;
}
}
}