From 21a6d6f0d61c4a24e2a899c57ad351f4632fb4f9 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Fri, 18 Jul 2025 02:19:41 +0300 Subject: [PATCH] Delete old migrations on restore (#14486) --- .../FullSystemBackup/BackupService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs index d439fcb18b..6e8936d536 100644 --- a/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs +++ b/Jellyfin.Server.Implementations/FullSystemBackup/BackupService.cs @@ -165,6 +165,13 @@ public class BackupService : IBackupService var historyRepository = dbContext.GetService(); 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);