Fix Surah seed tracking conflict on API startup retries.
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:
2026-10-09 22:57:27 +03:30
parent ae746d65ba
commit 92a2fdf6bc
6 changed files with 472 additions and 31 deletions
+4 -3
View File
@@ -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;
}