Interface IMigrationHistory
Tracks which migrations have already been applied, so the IMigrationRunner never applies one twice. A provider implements it over its own store (e.g. a dedicated MongoDB collection or Cosmos container), which also makes migration state visible and queryable.
public interface IMigrationHistory
Methods
EnsureCreatedAsync(CancellationToken)
Ensures the backing store for the history exists (idempotent). Called before the first read/record.
Task EnsureCreatedAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
GetAppliedIdsAsync(CancellationToken)
Gets the identifiers of the migrations already applied.
Task<IReadOnlyCollection<string>> GetAppliedIdsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
RecordAsync(AppliedMigration, CancellationToken)
Records a migration as applied.
Task RecordAsync(AppliedMigration migration, CancellationToken cancellationToken = default)
Parameters
migrationAppliedMigrationThe applied migration.
cancellationTokenCancellationTokenThe cancellation token.