aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJPVenson <github@jpb.email>2025-10-09 19:44:07 +0000
committerJPVenson <github@jpb.email>2025-10-09 19:44:07 +0000
commit0d4bd0495b2e74cb6f1d7f08cda43accb339b77e (patch)
tree6282c5a2116a1c7d857d4b3f322f2493d0159cd4
parent6f9c4dea6e74dd892da7f8192678c79b741fa967 (diff)
Add migration to remove artist and album artists from database
-rw-r--r--Jellyfin.Server/Migrations/Routines/CleanMusicArtist.cs45
1 files changed, 45 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..4dc4d6dc7
--- /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;
+
+/// <summary>
+/// Cleans up all Music artists that have been migrated in the 10.11 RC migrations.
+/// </summary>
+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);
+ }
+ }
+}