From 6f9c4dea6e74dd892da7f8192678c79b741fa967 Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Thu, 9 Oct 2025 11:00:36 -0500 Subject: [PATCH 1/3] Skip creating Person entities for Artist and AlbumArtist types --- Jellyfin.Server.Implementations/Item/PeopleRepository.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs index e03c136915..355ed64797 100644 --- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs +++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs @@ -95,6 +95,7 @@ public class PeopleRepository(IDbContextFactory dbProvider, I .ToArray(); var toAdd = people + .Where(e => e.Type is not PersonKind.Artist && e.Type is not PersonKind.AlbumArtist) .Where(e => !existingPersons.Any(f => f.Name == e.Name && f.PersonType == e.Type.ToString())) .Select(Map); context.Peoples.AddRange(toAdd); @@ -108,6 +109,11 @@ public class PeopleRepository(IDbContextFactory dbProvider, I foreach (var person in people) { + if (person.Type == PersonKind.Artist || person.Type == PersonKind.AlbumArtist) + { + continue; + } + var entityPerson = personsEntities.First(e => e.Name == person.Name && e.PersonType == person.Type.ToString()); var existingMap = existingMaps.FirstOrDefault(e => e.People.Name == person.Name && e.People.PersonType == person.Type.ToString() && e.Role == person.Role); if (existingMap is null) From 0d4bd0495b2e74cb6f1d7f08cda43accb339b77e Mon Sep 17 00:00:00 2001 From: JPVenson Date: Thu, 9 Oct 2025 19:44:07 +0000 Subject: [PATCH 2/3] Add migration to remove artist and album artists from database --- .../Migrations/Routines/CleanMusicArtist.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs diff --git a/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs new file mode 100644 index 0000000000..4dc4d6dc72 --- /dev/null +++ b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs @@ -0,0 +1,45 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Jellyfin.Data.Enums; +using Jellyfin.Database.Implementations; +using Jellyfin.Server.ServerSetupApp; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace Jellyfin.Server.Migrations.Routines; + +/// +/// Cleans up all Music artists that have been migrated in the 10.11 RC migrations. +/// +public class CleanMusicArtist : IAsyncMigrationRoutine +{ + private readonly IStartupLogger _startupLogger; + private readonly IDbContextFactory _dbContextFactory; + + /// + /// Initializes a new instance of the class. + /// + /// The startup logger. + /// The Db context factory. + public CleanMusicArtist(IStartupLogger startupLogger, IDbContextFactory dbContextFactory) + { + _startupLogger = startupLogger; + _dbContextFactory = dbContextFactory; + } + + /// + public async Task PerformAsync(CancellationToken cancellationToken) + { + var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false); + await using (context.ConfigureAwait(false)) + { + var peoples = context.Peoples.Where(e => e.PersonType == nameof(PersonKind.Artist) || e.PersonType == nameof(PersonKind.AlbumArtist)); + _startupLogger.LogInformation("Delete {Number} Artist and Album Artist person types from db", await peoples.CountAsync(cancellationToken).ConfigureAwait(false)); + + await peoples + .ExecuteDeleteAsync(cancellationToken) + .ConfigureAwait(false); + } + } +} From f01cddf273e578218c653ae085fee39310d8e21d Mon Sep 17 00:00:00 2001 From: JPVenson Date: Thu, 9 Oct 2025 19:45:43 +0000 Subject: [PATCH 3/3] Add migration attribute --- Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs index 4dc4d6dc72..d5c5f3d929 100644 --- a/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs +++ b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs @@ -12,6 +12,8 @@ namespace Jellyfin.Server.Migrations.Routines; /// /// Cleans up all Music artists that have been migrated in the 10.11 RC migrations. /// +[JellyfinMigration("2025-10-09T20:00:00", nameof(CleanMusicArtist))] +[JellyfinMigrationBackup(JellyfinDb = true)] public class CleanMusicArtist : IAsyncMigrationRoutine { private readonly IStartupLogger _startupLogger;