Trait migrate_core::Migration[][src]

pub trait Migration: Send + 'static {
    type Ctx: Send + 'static;
    #[must_use]
    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
;
#[must_use] 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 behavior of a single migration that may be applied or reversed using Migration::up() and Migration::down() methods respectively.

Associated Types

Defines context type injected for migration during its execution.

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

Required methods

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

For a migration it is safe to assume that preceding migrations were already applied and it may observe changes they made.

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

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

Implementors