Fixes FK on unconnected base items (#14863)

This commit is contained in:
JPVenson
2025-09-26 04:27:17 +03:00
committed by GitHub
parent 04ab362e59
commit 1736a566cc

View File

@@ -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",