< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Routines.StripEmbeddedLinkedChildren
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/20260911120000_StripEmbeddedLinkedChildren.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 49
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/29/2026 - 12:17:11 AM Line coverage: 0% (0/16) Total lines: 4411/13/2026 - 12:19:51 AM Line coverage: 0% (0/18) Total lines: 49

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
PerformAsync()100%210%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/20260911120000_StripEmbeddedLinkedChildren.cs

#LineLine coverage
 1using System.Threading;
 2using System.Threading.Tasks;
 3using Jellyfin.Database.Implementations;
 4using Microsoft.EntityFrameworkCore;
 5using Microsoft.Extensions.Logging;
 6
 7namespace Jellyfin.Server.Migrations.Routines;
 8
 9/// <summary>
 10/// Drops keys that no current property reads or writes from the serialized <c>BaseItems.Data</c> blob.
 11/// </summary>
 12[JellyfinMigration("2026-09-11T12:00:00", nameof(StripEmbeddedLinkedChildren))]
 13internal class StripEmbeddedLinkedChildren : IDatabaseMigrationRoutine
 14{
 15    private readonly ILogger<StripEmbeddedLinkedChildren> _logger;
 16    private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
 17
 18    public StripEmbeddedLinkedChildren(
 19        ILoggerFactory loggerFactory,
 20        IDbContextFactory<JellyfinDbContext> dbProvider)
 21    {
 022        _logger = loggerFactory.CreateLogger<StripEmbeddedLinkedChildren>();
 023        _dbProvider = dbProvider;
 024    }
 25
 26    /// <inheritdoc/>
 27    public async Task PerformAsync(CancellationToken cancellationToken)
 28    {
 029        var context = await _dbProvider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
 030        await using (context.ConfigureAwait(false))
 31        {
 32            // json_valid guards the rare malformed blob: json_remove would abort the statement on it,
 33            // and one bad row must not cost every other row the fix.
 034            var updated = await context.Database.ExecuteSqlRawAsync(
 035                """
 036                UPDATE "BaseItems"
 037                SET "Data" = json_remove("Data", '$.LinkedChildren', '$.ExtraIds', '$.SupportsExternalTransfer')
 038                WHERE "Data" IS NOT NULL
 039                  AND json_valid("Data") = 1
 040                  AND ("Data" LIKE '%"LinkedChildren"%'
 041                    OR "Data" LIKE '%"ExtraIds"%'
 042                    OR "Data" LIKE '%"SupportsExternalTransfer"%')
 043                """,
 044                cancellationToken).ConfigureAwait(false);
 45
 046            _logger.LogInformation("Dropped dead keys from the serialized data of {Count} items", updated);
 47        }
 048    }
 49}