瀏覽代碼

Throw exception on migration failure to halt application

Also save migration configuration after each migration instead of at the end in case an exception is thrown part way through the list
Mark Monteiro 5 年之前
父節點
當前提交
a0fdceb4bc
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      Jellyfin.Server/Migrations/MigrationRunner.cs

+ 2 - 6
Jellyfin.Server/Migrations/MigrationRunner.cs

@@ -59,16 +59,12 @@ namespace Jellyfin.Server.Migrations
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
                     logger.LogError(ex, "Could not apply migration {Name}", migrationRoutine.Name);
                     logger.LogError(ex, "Could not apply migration {Name}", migrationRoutine.Name);
-                    continue;
+                    throw;
                 }
                 }
 
 
+                // Mark the migration as completed
                 logger.LogInformation("Migration {Name} applied successfully", migrationRoutine.Name);
                 logger.LogInformation("Migration {Name} applied successfully", migrationRoutine.Name);
                 applied.Add(migrationRoutine.Name);
                 applied.Add(migrationRoutine.Name);
-            }
-
-            if (applied.Count > migrationOptions.Applied.Length)
-            {
-                logger.LogInformation("Some migrations were run, saving the state");
                 migrationOptions.Applied = applied.ToArray();
                 migrationOptions.Applied = applied.ToArray();
                 host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
                 host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
             }
             }