Delete old migrations on restore (#14486)

This commit is contained in:
JPVenson 2025-07-18 02:19:41 +03:00 committed by GitHub
parent aa77dfb92d
commit 21a6d6f0d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,6 +165,13 @@ public class BackupService : IBackupService
var historyRepository = dbContext.GetService<IHistoryRepository>();
await historyRepository.CreateIfNotExistsAsync().ConfigureAwait(false);
foreach (var item in await historyRepository.GetAppliedMigrationsAsync(CancellationToken.None).ConfigureAwait(false))
{
var insertScript = historyRepository.GetDeleteScript(item.MigrationId);
await dbContext.Database.ExecuteSqlRawAsync(insertScript).ConfigureAwait(false);
}
foreach (var item in historyEntries)
{
var insertScript = historyRepository.GetInsertScript(item);