LANCommander/LANCommander.SDK/Migrations/FileSystemMigration.cs
Aaron Powell e2b2654a61 Adding SQLite database migration step
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
2025-12-17 17:09:36 +11:00

29 lines
No EOL
906 B
C#

using LANCommander.SDK.Helpers;
using Microsoft.Extensions.Logging;
using Semver;
using System;
using System.Threading.Tasks;
namespace LANCommander.SDK.Migrations;
public abstract class FileSystemMigration(ILogger logger) : IMigration
{
public abstract SemVersion Version { get; }
public Task ExecuteAsync()
{
logger.LogInformation("Starting file system migration: {MigrationType}", GetType().Name);
if (EnvironmentHelper.IsRunningInContainer() && !AppPaths.ConfigDirectoryIsMounted())
throw new PlatformNotSupportedException(
"Aborting migration to avoid data loss. Application is running in a container but config directory is not mounted.");
logger.LogInformation("File system migration pre-move checks passed.");
return ExecutePostMoveAsync();
}
public abstract Task ExecutePostMoveAsync();
}