Created a new abstraction for migrations that have to run against the file system, so that we don't need to do the check in each migration. Adding the default DB name to the settings so it's got a const value. Updated the Settings migrator to check a few more places
26 lines
No EOL
790 B
C#
26 lines
No EOL
790 B
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)
|
|
{
|
|
builder.Services.AddScoped<IMigration, CombineSettingsYaml>();
|
|
builder.Services.AddScoped<IMigration, SqliteDatabaseLocation>();
|
|
builder.Services.AddScoped<IMigration, EncapsulateUserData>();
|
|
|
|
return builder;
|
|
}
|
|
|
|
public static async Task<WebApplication> RunApplicationMigrationsAsync(this WebApplication app)
|
|
{
|
|
var migrationService = app.Services.GetRequiredService<MigrationService>();
|
|
|
|
await migrationService.MigrateAsync();
|
|
|
|
return app;
|
|
}
|
|
} |