< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Routines.UpdateNormalizedUsername
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/20260522092304_UpdateNormalizedUsername.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 44
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/27/2026 - 12:15:38 AM Line coverage: 0% (0/9) Branch coverage: 0% (0/2) Total lines: 44 5/27/2026 - 12:15:38 AM Line coverage: 0% (0/9) Branch coverage: 0% (0/2) Total lines: 44

Metrics

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

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/20260522092304_UpdateNormalizedUsername.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Jellyfin.Database.Implementations;
 5using MediaBrowser.Controller.Configuration;
 6using Microsoft.EntityFrameworkCore;
 7
 8namespace Jellyfin.Server.Migrations.Routines;
 9
 10/// <summary>
 11/// Part 2 Migration for NormalisedUsername.
 12/// </summary>
 13[JellyfinMigration("2026-05-22T09:23:04", nameof(UpdateNormalizedUsername), Stage = Stages.JellyfinMigrationStageTypes.C
 14#pragma warning disable SA1649 // File name should match first type name
 15public class UpdateNormalizedUsername : IAsyncMigrationRoutine
 16#pragma warning restore SA1649 // File name should match first type name
 17{
 18    private readonly IDbContextFactory<JellyfinDbContext> _contextFactory;
 19
 20    /// <summary>
 21    /// Initializes a new instance of the <see cref="UpdateNormalizedUsername"/> class.
 22    /// </summary>
 23    /// <param name="contextFactory">Db Context factory.</param>
 24    public UpdateNormalizedUsername(IDbContextFactory<JellyfinDbContext> contextFactory)
 25    {
 026        _contextFactory = contextFactory;
 027    }
 28
 29    /// <inheritdoc/>
 30    public async Task PerformAsync(CancellationToken cancellationToken)
 31    {
 032        var dbContext = await _contextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
 033        await using (dbContext.ConfigureAwait(false))
 34        {
 035            var users = await dbContext.Users.ToListAsync(cancellationToken).ConfigureAwait(false);
 036            foreach (var user in users)
 37            {
 038                user.NormalizedUsername = user.Username.ToUpperInvariant();
 39            }
 40
 041            await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
 42        }
 043    }
 44}