Clean error alerts and harden startup migration

This commit is contained in:
2026-04-11 18:07:20 +02:00
parent b52371ea79
commit 48cd83b442
5 changed files with 47 additions and 14 deletions
@@ -870,7 +870,17 @@ public static class StartupInitializationExtensions
}
}
db.Database.Migrate();
try
{
using var migrationScope = app.Services.CreateScope();
var migrationDb = migrationScope.ServiceProvider.GetRequiredService<JobTrackerContext>();
migrationDb.Database.Migrate();
}
catch (Exception ex)
{
app.Logger.LogError(ex, "Database migration failed during startup initialization.");
throw;
}
// Optional: seed an initial admin user for local username/password login.
// Set Auth:AdminEmail and Auth:AdminPassword to enable.