mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-01 04:34:26 -04:00
Use a Guid to uniquely identify migrations instead of a string name
Also use a list instead of an array to store executed migrations in the configuration class
This commit is contained in:
parent
8dbb1c9257
commit
72bf920291
@ -9,7 +9,12 @@ namespace Jellyfin.Server.Migrations
|
|||||||
internal interface IMigrationRoutine
|
internal interface IMigrationRoutine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Migrations
|
namespace Jellyfin.Server.Migrations
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -10,14 +13,12 @@ namespace Jellyfin.Server.Migrations
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public MigrationOptions()
|
public MigrationOptions()
|
||||||
{
|
{
|
||||||
Applied = System.Array.Empty<string>();
|
Applied = new List<Guid>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CA1819 // Properties should not return arrays
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of applied migration routine names.
|
/// Gets the list of applied migration routine names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Applied { get; set; }
|
public List<Guid> Applied { get; }
|
||||||
#pragma warning restore CA1819 // Properties should not return arrays
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,22 +29,20 @@ namespace Jellyfin.Server.Migrations
|
|||||||
var logger = loggerFactory.CreateLogger<MigrationRunner>();
|
var logger = loggerFactory.CreateLogger<MigrationRunner>();
|
||||||
var migrationOptions = ((IConfigurationManager)host.ServerConfigurationManager).GetConfiguration<MigrationOptions>(MigrationsListStore.StoreKey);
|
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.
|
// If startup wizard is not finished, this is a fresh install.
|
||||||
// Don't run any migrations, just mark all of them as applied.
|
// 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");
|
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);
|
host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var applied = migrationOptions.Applied.ToList();
|
|
||||||
|
|
||||||
for (var i = 0; i < Migrations.Length; i++)
|
for (var i = 0; i < Migrations.Length; i++)
|
||||||
{
|
{
|
||||||
var migrationRoutine = Migrations[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);
|
logger.LogDebug("Skipping migration '{Name}' since it is already applied", migrationRoutine.Name);
|
||||||
continue;
|
continue;
|
||||||
@ -64,8 +62,7 @@ namespace Jellyfin.Server.Migrations
|
|||||||
|
|
||||||
// Mark the migration as completed
|
// 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);
|
migrationOptions.Applied.Add(migrationRoutine.Id);
|
||||||
migrationOptions.Applied = applied.ToArray();
|
|
||||||
host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
|
host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
|
||||||
logger.LogDebug("Migration '{Name}' marked as applied in configuration.", migrationRoutine.Name);
|
logger.LogDebug("Migration '{Name}' marked as applied in configuration.", migrationRoutine.Name);
|
||||||
}
|
}
|
||||||
|
@ -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""]}}",
|
@"{""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/>
|
/// <inheritdoc/>
|
||||||
public string Name => "CreateLoggingConfigHeirarchy";
|
public string Name => "CreateLoggingConfigHeirarchy";
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ namespace Jellyfin.Server.Migrations.Routines
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class DisableTranscodingThrottling : IMigrationRoutine
|
internal class DisableTranscodingThrottling : IMigrationRoutine
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public Guid Id => Guid.Parse("{4124C2CD-E939-4FFB-9BE9-9B311C413638}");
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Name => "DisableTranscodingThrottling";
|
public string Name => "DisableTranscodingThrottling";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user