Changed the IMigration interface to have a series of steps, first a method to indicate that the migration should run, next some pre-checks (like is it in a container), and lastly the actual execution. Next, the settings and folder migrations are broken into individual migrations, which means that it's a lot more obvious which ones run and which ones are skipped.
43 lines
No EOL
1.8 KiB
C#
43 lines
No EOL
1.8 KiB
C#
using LANCommander.SDK.Migrations;
|
|
using LANCommander.SDK.Services;
|
|
using LANCommander.Server.Migrations;
|
|
|
|
namespace LANCommander.Server.Startup;
|
|
|
|
public static class Migrations
|
|
{
|
|
public static WebApplicationBuilder AddMigrations(this WebApplicationBuilder builder)
|
|
{
|
|
// Individual settings file migrations
|
|
builder.Services.AddScoped<IMigration, CombineSettingsYamlFromRoot>();
|
|
builder.Services.AddScoped<IMigration, CombineSettingsServerYamlFromRoot>();
|
|
builder.Services.AddScoped<IMigration, CombineSettingsYamlFromConfig>();
|
|
builder.Services.AddScoped<IMigration, CombineSettingsServerYamlFromConfig>();
|
|
|
|
// Database location migrations
|
|
builder.Services.AddScoped<IMigration, SqliteDatabaseLocationMigration>();
|
|
|
|
// Individual path migrations
|
|
builder.Services.AddScoped<IMigration, MoveBackupsMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveMediaMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveSavesMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveSnippetsMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveUploadMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveUploadsMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveServersMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveUpdatesMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveLauncherMigration>();
|
|
builder.Services.AddScoped<IMigration, MoveLogsMigration>();
|
|
|
|
return builder;
|
|
}
|
|
|
|
public static async Task<WebApplication> RunApplicationMigrationsAsync(this WebApplication app)
|
|
{
|
|
var migrationService = app.Services.GetRequiredService<MigrationService>();
|
|
|
|
await migrationService.MigrateAsync();
|
|
|
|
return app;
|
|
}
|
|
} |