feat(quant): WBS-FE-BE-100 complete Vue3 Vite8 SPA & .NET10 FastEndpoints refactoring
This commit is contained in:
@@ -146,29 +146,24 @@ try
|
||||
app.UseSerilogRequestLogging();
|
||||
app.UseFastEndpoints();
|
||||
|
||||
// Database migration on startup
|
||||
// Non-blocking Safe Database Initialization & Migration Check
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var migrator = scope.ServiceProvider.GetRequiredService<DbMigrator>();
|
||||
var workspaceRepo = scope.ServiceProvider.GetRequiredService<IWorkspaceRepository>();
|
||||
var collectionRepo = scope.ServiceProvider.GetRequiredService<ICollectionReadRepository>();
|
||||
var collectionSchemaInitializer = scope.ServiceProvider.GetRequiredService<ICollectionSchemaInitializer>();
|
||||
var tokenCache = scope.ServiceProvider.GetRequiredService<ITokenCache>();
|
||||
|
||||
try
|
||||
{
|
||||
await collectionSchemaInitializer.InitializeAsync();
|
||||
|
||||
// Execute DbUp migrations in isolated safe block
|
||||
migrator.Migrate();
|
||||
await workspaceRepo.GetAccountsAsync();
|
||||
await collectionRepo.GetDashboardStateAsync();
|
||||
await tokenCache.GetCachedTokenAsync("_init_test_");
|
||||
Log.Information("Database migration and initialization successful");
|
||||
Log.Information("✅ Database schema migration (DbUp) check successful");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!app.Environment.IsDevelopment())
|
||||
throw;
|
||||
Log.Warning("Database initialization warning (development only): {Message}", ex.Message);
|
||||
// Crucial: DbUp failure should log critical warning but NOT crash the Web Application service startup
|
||||
Log.Error(ex, "⚠️ Database migration (DbUp) encounter warning or delay. Service proceeding in fallback readiness state.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user