Skip to content
Tracon

IMigrationApplier

Namespace Tracon · Assembly Tracon.Abstractions.dll

Applies the pending migrations of the active SQL persistence provider.

public interface IMigrationApplier

Each Use* extension (UsePostgreSql, UseSqlServer, and UseSqlite) registers this interface with Replace, resolving to the same instance as MigrationRunner.

This exists as its own interface, separate from ISqlPersistenceDiagnostics, because MigrationRunner is compiled from source SHARED across the three SQL provider packages (Tracon.Sql.Shared): a consumer that references more than one provider - the tracon global tool does, for its migrate command - sees three DIFFERENT MigrationRunner types with the same name, and an unqualified reference to it does not compile (CS0433). This interface lives in Tracon.Abstractions, referenced identically by all three, so IServiceProvider.GetRequiredService<IMigrationApplier> resolves without needing to know which provider is active.

DI lifetime — singleton. Registered as a singleton with Replace by whichever SQL provider is active.

Applies every pending migration, in order.

ValueTask<int> ApplyAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<int>

The number of migrations applied.