Trait migrate_core::Migration[][src]

pub trait Migration: Send + 'static {
    type Ctx: Send + 'static;
    fn up<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 mut Self::Ctx
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn down<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 mut Self::Ctx
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

Contains the behavior of a single migration that may be applied or reversed using Migration::up() and Migration::down() methods respectively.

Associated Types

Defines that type of the context that will be injected for the migration to use during its execution.

The context will be created by MigrationCtxProvider and looked up by its type_id().

Required methods

Run the forward migration logic. The given Migration::Ctx should be used to perform the execution. The context should take care to to commit the changes to the target migration object (e.g. a database) or just collect the diagnostic info about the planned operations according to the MigrationRunMode.

The migration is safe to assume that migrations that precede it were already applied and it may observe the changes made by them.

Similar to Migration::up(), but applies the migration logic in reverse direction. It may safely assume that this same Migration::up() method was run and it may observe the changes made by the forward migration logic.

This method should cancel the changes made by the forward migration logic and basically rollback the state of the migration object to the state it was before Migration::up() was called.

Implementors