aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJPVenson <github@jpb.email>2024-11-15 09:08:27 +0000
committerJPVenson <github@jpb.email>2024-11-15 09:08:27 +0000
commit19e55f4309714b31149615fd13a37a5a2eb94160 (patch)
tree22def203644546c11d0da16eafdceb927c9b9cca
parent92eb983c61b7a24e0d781fbbe196aa2810bf4aba (diff)
Fixed migration referencing non-existing Items
-rw-r--r--Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs
index de4894198..4a379a183 100644
--- a/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs
+++ b/Jellyfin.Server/Migrations/Routines/MigrateLibraryDb.cs
@@ -109,7 +109,11 @@ public class MigrateLibraryDb : IMigrationRoutine
_logger.LogInformation("Start moving ItemValues.");
// do not migrate inherited types as they are now properly mapped in search and lookup.
- var itemValueQuery = "select ItemId, Type, Value, CleanValue FROM ItemValues WHERE Type <> 6";
+ var itemValueQuery =
+ """
+ SELECT ItemId, Type, Value, CleanValue FROM ItemValues
+ WHERE Type <> 6 AND EXISTS(SELECT 1 FROM TypedBaseItems WHERE TypedBaseItems.guid = ItemValues.ItemId)
+ """;
dbContext.ItemValues.ExecuteDelete();
// EFCores local lookup sucks. We cannot use context.ItemValues.Local here because its just super slow.