attempt migrations at api startup
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 8s

This commit is contained in:
2026-03-14 15:52:43 -05:00
parent 28f222ee28
commit 2011d1fb36

View File

@@ -57,4 +57,19 @@ if (app.Environment.IsEnvironment("Development")) {
app.MapControllers(); app.MapControllers();
// attempt enitity-framework migrations at startup. love you stack overflow
using (var scope = app.Services.CreateScope()) {
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var retries = 10;
while (retries-- > 0) {
try {
db.Database.Migrate();
break;
} catch {
Thread.Sleep(5000);
}
}
}
app.Run(); app.Run();