diff options
| author | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-03-08 17:40:30 +0100 |
|---|---|---|
| committer | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-03-08 17:40:30 +0100 |
| commit | 9e89cbbc3ad451b510a00fd7e214f6b942176f47 (patch) | |
| tree | 2c4e7dff0fa608296cce2863b4aca72f14714c56 /Jellyfin.Server | |
| parent | 72bf920291d1c486aaf66544ccd6eb64c13e254b (diff) | |
Store migration names alongside Ids in configuration in order to assist with development/debugging
Diffstat (limited to 'Jellyfin.Server')
| -rw-r--r-- | Jellyfin.Server/Migrations/MigrationOptions.cs | 4 | ||||
| -rw-r--r-- | Jellyfin.Server/Migrations/MigrationRunner.cs | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Jellyfin.Server/Migrations/MigrationOptions.cs b/Jellyfin.Server/Migrations/MigrationOptions.cs index d95354145..816dd9ee7 100644 --- a/Jellyfin.Server/Migrations/MigrationOptions.cs +++ b/Jellyfin.Server/Migrations/MigrationOptions.cs @@ -13,12 +13,12 @@ namespace Jellyfin.Server.Migrations /// </summary> public MigrationOptions() { - Applied = new List<Guid>(); + Applied = new List<(Guid Id, string Name)>(); } /// <summary> /// Gets the list of applied migration routine names. /// </summary> - public List<Guid> Applied { get; } + public List<(Guid Id, string Name)> Applied { get; } } } diff --git a/Jellyfin.Server/Migrations/MigrationRunner.cs b/Jellyfin.Server/Migrations/MigrationRunner.cs index 2081143d2..b5ea04dca 100644 --- a/Jellyfin.Server/Migrations/MigrationRunner.cs +++ b/Jellyfin.Server/Migrations/MigrationRunner.cs @@ -33,16 +33,18 @@ namespace Jellyfin.Server.Migrations { // 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.AddRange(Migrations.Select(m => m.Id)); + logger.LogInformation("Marking all known migrations as applied because this is a fresh install"); + migrationOptions.Applied.AddRange(Migrations.Select(m => (m.Id, m.Name))); host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions); return; } + var appliedMigrationIds = migrationOptions.Applied.Select(m => m.Id).ToHashSet(); + for (var i = 0; i < Migrations.Length; i++) { var migrationRoutine = Migrations[i]; - if (migrationOptions.Applied.Contains(migrationRoutine.Id)) + if (appliedMigrationIds.Contains(migrationRoutine.Id)) { logger.LogDebug("Skipping migration '{Name}' since it is already applied", migrationRoutine.Name); continue; @@ -62,7 +64,7 @@ namespace Jellyfin.Server.Migrations // Mark the migration as completed logger.LogInformation("Migration '{Name}' applied successfully", migrationRoutine.Name); - migrationOptions.Applied.Add(migrationRoutine.Id); + migrationOptions.Applied.Add((migrationRoutine.Id, migrationRoutine.Name)); host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions); logger.LogDebug("Migration '{Name}' marked as applied in configuration.", migrationRoutine.Name); } |
