The Free Software Media System - Server Backend & API
Use a Guid to uniquely identify migrations instead of a string name
Mark Monteiro72bf920291d1
diff --git a/Jellyfin.Server/Migrations/IMigrationRoutine.cs b/Jellyfin.Server/Migrations/IMigrationRoutine.csindex 20a3aa3d6a..eab995d67e 100644--- a/Jellyfin.Server/Migrations/IMigrationRoutine.cs+++ b/Jellyfin.Server/Migrations/IMigrationRoutine.cs@@ -9,7 +9,12 @@ namespace Jellyfin.Server.Migrationsinternal interface IMigrationRoutine{/// <summary>- /// Gets the name of the migration, must be unique.+ /// Gets the unique id for this migration. This should never be modified after the migration has been created.+ /// </summary>+ public Guid Id { get; }++ /// <summary>+ /// Gets the display name of the migration./// </summary>public string Name { get; }diff --git a/Jellyfin.Server/Migrations/MigrationOptions.cs b/Jellyfin.Server/Migrations/MigrationOptions.csindex 6b7831158f..d95354145e 100644--- a/Jellyfin.Server/Migrations/MigrationOptions.cs+++ b/Jellyfin.Server/Migrations/MigrationOptions.cs@@ -1,3 +1,6 @@+using System;+using System.Collections.Generic;+namespace Jellyfin.Server.Migrations{/// <summary>@@ -10,14 +13,12 @@ namespace Jellyfin.Server.Migrations/// </summary>public MigrationOptions(){- Applied = System.Array.Empty<string>();+ Applied = new List<Guid>();}-#pragma warning disable CA1819 // Properties should not return arrays/// <summary>- /// Gets or sets the list of applied migration routine names.+ /// Gets the list of applied migration routine names./// </summary>- public string[] Applied { get; set; }-#pragma warning restore CA1819 // Properties should not return arrays+ public List<Guid> Applied { get; }}}diff --git a/Jellyfin.Server/Migrations/MigrationRunner.cs b/Jellyfin.Server/Migrations/MigrationRunner.csindex 821f51c02f..2081143d20 100644--- a/Jellyfin.Server/Migrations/MigrationRunner.cs+++ b/Jellyfin.Server/Migrations/MigrationRunner.cs@@ -29,22 +29,20 @@ namespace Jellyfin.Server.Migrationsvar logger = loggerFactory.CreateLogger<MigrationRunner>();var migrationOptions = ((IConfigurationManager)host.ServerConfigurationManager).GetConfiguration<MigrationOptions>(MigrationsListStore.StoreKey);- if (!host.ServerConfigurationManager.Configuration.IsStartupWizardCompleted && migrationOptions.Applied.Length == 0)+ if (!host.ServerConfigurationManager.Configuration.IsStartupWizardCompleted && migrationOptions.Applied.Count == 0){// If startup wizard is not finished, this is a fresh install.// Don't run any migrations, just mark all of them as applied.logger.LogInformation("Marking all known migrations as applied because this is fresh install");- migrationOptions.Applied = Migrations.Select(m => m.Name).ToArray();+ migrationOptions.Applied.AddRange(Migrations.Select(m => m.Id));host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);return;}- var applied = migrationOptions.Applied.ToList();-for (var i = 0; i < Migrations.Length; i++){var migrationRoutine = Migrations[i];- if (applied.Contains(migrationRoutine.Name))+ if (migrationOptions.Applied.Contains(migrationRoutine.Id)){logger.LogDebug("Skipping migration '{Name}' since it is already applied", migrationRoutine.Name);continue;@@ -64,8 +62,7 @@ namespace Jellyfin.Server.Migrations// Mark the migration as completedlogger.LogInformation("Migration '{Name}' applied successfully", migrationRoutine.Name);- applied.Add(migrationRoutine.Name);- migrationOptions.Applied = applied.ToArray();+ migrationOptions.Applied.Add(migrationRoutine.Id);host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);logger.LogDebug("Migration '{Name}' marked as applied in configuration.", migrationRoutine.Name);}diff --git a/Jellyfin.Server/Migrations/Routines/CreateUserLoggingConfigFile.cs b/Jellyfin.Server/Migrations/Routines/CreateUserLoggingConfigFile.csindex 834099ea05..3bc32c0478 100644--- a/Jellyfin.Server/Migrations/Routines/CreateUserLoggingConfigFile.cs+++ b/Jellyfin.Server/Migrations/Routines/CreateUserLoggingConfigFile.cs@@ -36,6 +36,9 @@ namespace Jellyfin.Server.Migrations.Routines@"{""Serilog"":{""MinimumLevel"":""Information"",""WriteTo"":[{""Name"":""Console"",""Args"":{""outputTemplate"":""[{Timestamp:HH:mm:ss}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message:lj}{NewLine}{Exception}""}},{""Name"":""Async"",""Args"":{""configure"":[{""Name"":""File"",""Args"":{""path"":""%JELLYFIN_LOG_DIR%//log_.log"",""rollingInterval"":""Day"",""retainedFileCountLimit"":3,""rollOnFileSizeLimit"":true,""fileSizeLimitBytes"":100000000,""outputTemplate"":""[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] [{ThreadId}] {SourceContext}:{Message}{NewLine}{Exception}""}}]}}],""Enrich"":[""FromLogContext"",""WithThreadId""]}}",};+ /// <inheritdoc/>+ public Guid Id => Guid.Parse("{EF103419-8451-40D8-9F34-D1A8E93A1679}");+/// <inheritdoc/>public string Name => "CreateLoggingConfigHeirarchy";diff --git a/Jellyfin.Server/Migrations/Routines/DisableTranscodingThrottling.cs b/Jellyfin.Server/Migrations/Routines/DisableTranscodingThrottling.csindex 279e7bbea5..673f0e4155 100644--- a/Jellyfin.Server/Migrations/Routines/DisableTranscodingThrottling.cs+++ b/Jellyfin.Server/Migrations/Routines/DisableTranscodingThrottling.cs@@ -12,6 +12,9 @@ namespace Jellyfin.Server.Migrations.Routines/// </summary>internal class DisableTranscodingThrottling : IMigrationRoutine{+ /// <inheritdoc/>+ public Guid Id => Guid.Parse("{4124C2CD-E939-4FFB-9BE9-9B311C413638}");+/// <inheritdoc/>public string Name => "DisableTranscodingThrottling";