< 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: 16
Coverable lines: 16
Total lines: 44
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: 44

Metrics

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

File(s)

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

#LineLine coverage
 1using Jellyfin.Database.Implementations;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.Extensions.Logging;
 4
 5namespace Jellyfin.Server.Migrations.Routines;
 6
 7/// <summary>
 8/// Drops keys that no current property reads or writes from the serialized <c>BaseItems.Data</c> blob.
 9/// </summary>
 10[JellyfinMigration("2026-09-11T12:00:00", nameof(StripEmbeddedLinkedChildren))]
 11internal class StripEmbeddedLinkedChildren : IDatabaseMigrationRoutine
 12{
 13    private readonly ILogger<StripEmbeddedLinkedChildren> _logger;
 14    private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
 15
 16    public StripEmbeddedLinkedChildren(
 17        ILoggerFactory loggerFactory,
 18        IDbContextFactory<JellyfinDbContext> dbProvider)
 19    {
 020        _logger = loggerFactory.CreateLogger<StripEmbeddedLinkedChildren>();
 021        _dbProvider = dbProvider;
 022    }
 23
 24    /// <inheritdoc/>
 25    public void Perform()
 26    {
 027        using var context = _dbProvider.CreateDbContext();
 28
 29        // json_valid guards the rare malformed blob: json_remove would abort the statement on it,
 30        // and one bad row must not cost every other row the fix.
 031        var updated = context.Database.ExecuteSqlRaw(
 032            """
 033            UPDATE "BaseItems"
 034            SET "Data" = json_remove("Data", '$.LinkedChildren', '$.ExtraIds', '$.SupportsExternalTransfer')
 035            WHERE "Data" IS NOT NULL
 036              AND json_valid("Data") = 1
 037              AND ("Data" LIKE '%"LinkedChildren"%'
 038                OR "Data" LIKE '%"ExtraIds"%'
 039                OR "Data" LIKE '%"SupportsExternalTransfer"%')
 040            """);
 41
 042        _logger.LogInformation("Dropped dead keys from the serialized data of {Count} items", updated);
 043    }
 44}