fix migrations for new databases (#2217)

This commit is contained in:
Jason Dove
2025-07-28 20:18:08 +00:00
committed by GitHub
parent 74733a8026
commit 00f40c2568
@@ -40,14 +40,18 @@ public class DatabaseMigratorService : BackgroundService
await dbContext.Database.MigrateAsync("Add_MediaFilePathHash", stoppingToken);
}
// this can't be part of a migration, so we have to stop here and run some sql
await PopulatePathHashes(dbContext);
List<string> appliedMigrations = await dbContext.Database
.GetAppliedMigrationsAsync(stoppingToken)
.Map(l => l.ToList());
if (appliedMigrations.Count > 0)
{
// this can't be part of a migration, so we have to stop here and run some sql
await PopulatePathHashes(dbContext);
}
// then continue migrating
if (pendingMigrations.Count > 0)
{
await dbContext.Database.MigrateAsync(stoppingToken);
}
await dbContext.Database.MigrateAsync(stoppingToken);
await DbInitializer.Initialize(dbContext, stoppingToken);