aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2025-10-11 17:20:31 -0400
committerGitHub <noreply@github.com>2025-10-11 17:20:31 -0400
commitcf3edd98752fe6902e0e2e373543c0fd26c75da9 (patch)
tree68ca30cdc96f2d982697b72e2598776acf976a51 /Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs
parentef0131ad6967b4c3268859af09c7b246342b3118 (diff)
parentf01cddf273e578218c653ae085fee39310d8e21d (diff)
Merge pull request #14971 from theguymadmax/skip-artist-album-persontype
Skip creating Person entities for Artist and AlbumArtist types
Diffstat (limited to 'Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs')
-rw-r--r--Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs
new file mode 100644
index 000000000..d5c5f3d92
--- /dev/null
+++ b/Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs
@@ -0,0 +1,47 @@
+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;
+
+/// <summary>
+/// Cleans up all Music artists that have been migrated in the 10.11 RC migrations.
+/// </summary>
+[JellyfinMigration("2025-10-09T20:00:00", nameof(CleanMusicArtist))]
+[JellyfinMigrationBackup(JellyfinDb = true)]
+public class CleanMusicArtist : IAsyncMigrationRoutine
+{
+ private readonly IStartupLogger<CleanMusicArtist> _startupLogger;
+ private readonly IDbContextFactory<JellyfinDbContext> _dbContextFactory;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CleanMusicArtist"/> class.
+ /// </summary>
+ /// <param name="startupLogger">The startup logger.</param>
+ /// <param name="dbContextFactory">The Db context factory.</param>
+ public CleanMusicArtist(IStartupLogger<CleanMusicArtist> startupLogger, IDbContextFactory<JellyfinDbContext> dbContextFactory)
+ {
+ _startupLogger = startupLogger;
+ _dbContextFactory = dbContextFactory;
+ }
+
+ /// <inheritdoc/>
+ 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);
+ }
+ }
+}