aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJPVenson <github@jpb.email>2025-09-26 04:27:17 +0300
committerGitHub <noreply@github.com>2025-09-25 19:27:17 -0600
commit1736a566ccad07142bde86c0b450175f943e5848 (patch)
tree4a890450b809fc4d9a9e7a66e295459bfa2fde1e
parent04ab362e59addcfbfbf6be00bb66cd0d3cc68cc5 (diff)
Fixes FK on unconnected base items (#14863)
-rw-r--r--src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250913211637_AddProperParentChildRelationBaseItemWithCascade.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250913211637_AddProperParentChildRelationBaseItemWithCascade.cs b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250913211637_AddProperParentChildRelationBaseItemWithCascade.cs
index 77f41edad..11c84d44c 100644
--- a/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250913211637_AddProperParentChildRelationBaseItemWithCascade.cs
+++ b/src/Jellyfin.Database/Jellyfin.Database.Providers.Sqlite/Migrations/20250913211637_AddProperParentChildRelationBaseItemWithCascade.cs
@@ -10,6 +10,28 @@ namespace Jellyfin.Server.Implementations.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.Sql("""
+DELETE FROM BaseItems
+ WHERE
+ ParentId IS NOT NULL
+ AND
+ NOT EXISTS(SELECT 1 FROM BaseItems parent WHERE ParentId = parent.Id);
+DELETE FROM BaseItems
+ WHERE
+ ParentId IS NOT NULL
+ AND
+ NOT EXISTS(SELECT 1 FROM BaseItems parent WHERE ParentId = parent.Id);
+DELETE FROM BaseItems
+ WHERE
+ ParentId IS NOT NULL
+ AND
+ NOT EXISTS(SELECT 1 FROM BaseItems parent WHERE ParentId = parent.Id);
+DELETE FROM BaseItems
+ WHERE
+ ParentId IS NOT NULL
+ AND
+ NOT EXISTS(SELECT 1 FROM BaseItems parent WHERE ParentId = parent.Id);
+""");
migrationBuilder.AddForeignKey(
name: "FK_BaseItems_BaseItems_ParentId",
table: "BaseItems",