Fix Surah seed tracking conflict on API startup retries.
build-and-deploy / deploy (push) Has been cancelled
build-and-deploy / deploy (push) Has been cancelled
Use idempotent seed, fresh DbContext per retry, and explicit Surah/Tafsir keys.
This commit is contained in:
@@ -40,14 +40,15 @@ builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var audioRoot = app.Configuration["AudioRoot"] ?? "/data/audio";
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var audioRoot = app.Configuration["AudioRoot"] ?? "/data/audio";
|
||||
// Fresh scope each attempt so a failed seed cannot leave tracked entities.
|
||||
using var scope = app.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
await DbSeeder.SeedAsync(db, audioRoot);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user