Table of Contents

Class Migration

Namespace
CL.MySQL2.Models
Assembly
CL.MySQL2.dll

Convenience base for IMigration. Supplies Version and Description from the constructor and a DownAsync(IMigrationContext, CancellationToken) that throws (override it to make the migration reversible).

public abstract class Migration : IMigration
Inheritance
Migration
Implements
Inherited Members

Remarks

Note that MySQL implicitly commits on DDL. A migration that mixes ALTER with data changes is therefore not atomic — prefer keeping UpAsync(IMigrationContext, CancellationToken) steps idempotent and splitting heavy DDL and heavy backfill into separate migrations.

Constructors

Migration(string, int, string)

protected Migration(string appVersion, int order, string description)

Parameters

appVersion string

The app version this migration ships with (e.g. "1.4.0").

order int

Order within that version (applied ascending).

description string

Human-readable description.

Properties

Description

Human-readable description recorded in the __migrations history.

public string Description { get; }

Property Value

string

Version

The migration's ordered position.

public MigrationVersion Version { get; }

Property Value

MigrationVersion

Methods

DownAsync(IMigrationContext, CancellationToken)

Reverts the migration. Override to enable rollback; the default Migration base throws NotSupportedException.

public virtual Task DownAsync(IMigrationContext ctx, CancellationToken ct)

Parameters

ctx IMigrationContext
ct CancellationToken

Returns

Task

UpAsync(IMigrationContext, CancellationToken)

Applies the migration. Runs inside a transaction owned by the runner.

public abstract Task UpAsync(IMigrationContext ctx, CancellationToken ct)

Parameters

ctx IMigrationContext
ct CancellationToken

Returns

Task