浏览代码

Delete old migrations on restore (#14486)

JPVenson 3 月之前
父节点
当前提交
21a6d6f0d6
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs

+ 7 - 0
Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs

@@ -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);