Trait Migration

Source
pub trait Migration: Send + Sync {
    type Ctx: MigrationContext;

    // Required methods
    fn migration_id(&self) -> MigrationId;
    fn content(&self) -> String;
    fn no_tx(&self) -> bool;
    fn build<'a>(
        &'a self,
        ctx: &'a mut Self::Ctx,
    ) -> Pin<Box<dyn Future<Output = Result<Query, Error>> + Send + 'a>>;

    // Provided methods
    fn version(&self) -> i64 { ... }
    fn to_applied(
        &self,
        duration_ms: i64,
        applied_at: DateTime<Utc>,
        content: &str,
    ) -> AppliedMigration { ... }
}
Expand description

A single migration in a migration set.

Required Associated Types§

Source

type Ctx: MigrationContext

A migration context that is sufficient to build this migration.

Required Methods§

Source

fn migration_id(&self) -> MigrationId

Get the MigrationId for this migration.

Source

fn content(&self) -> String

The raw file content of the migration source file, or when stored as an applied migration in the history table, it is the query that was ran.

Source

fn no_tx(&self) -> bool

Whether this migration should not be applied in a database transaction.

Source

fn build<'a>( &'a self, ctx: &'a mut Self::Ctx, ) -> Pin<Box<dyn Future<Output = Result<Query, Error>> + Send + 'a>>

Produce a future resolving to the migration query when awaited.

Provided Methods§

Source

fn version(&self) -> i64

The migration version.

Source

fn to_applied( &self, duration_ms: i64, applied_at: DateTime<Utc>, content: &str, ) -> AppliedMigration

Convert this migration to an AppliedMigration assuming that it was successfully applied.

Implementors§