LANCommander/LANCommander.SDK/Migrations/IMigration.cs
Aaron Powell 8600bae9ec Overhauling the migrations to be a bit more explicit in the steps that they go through.
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.
2025-12-18 10:57:26 +11:00

34 lines
1.3 KiB
C#

using Semver;
using System.Threading.Tasks;
namespace LANCommander.SDK.Migrations;
public interface IMigration
{
/// <summary>
/// The version of the Migration.
/// </summary>
public SemVersion Version { get; }
/// <summary>
/// Asynchronously determines whether the associated operation should be executed.
/// </summary>
/// <returns>A task that represents the asynchronous operation. The task result is <see langword="true"/> if the operation
/// should be executed; otherwise, <see langword="false"/>.</returns>
public Task<bool> ShouldExecuteAsync();
/// <summary>
/// Performs any necessary pre-checks before executing the migration.
/// </summary>
/// <returns>A task that represents the asynchronous operation. The task result is <see lang="true"/> if pre-checks pass; otherwise, <see langword="false"/>.</returns>
public Task<bool> PerformPreChecksAsync();
/// <summary>
/// Executes the migration asynchronously.
/// </summary>
/// <remarks>
/// This will only be called if <see cref="ShouldExecuteAsync"/> returns <see langword="true"/> and <see cref="PerformPreChecksAsync"/> returns <see langword="true"/>.
/// </remarks>
public Task ExecuteAsync();
}