attempt migrations at api startup
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 8s
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 8s
This commit is contained in:
@@ -57,4 +57,19 @@ if (app.Environment.IsEnvironment("Development")) {
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user