Trait Migration

Source
pub trait Migration: Sync + Send {
    // Required method
    fn up<'life0, 'async_trait>(
        &'life0 self,
        env: Env,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn down<'life0, 'async_trait>(
        &'life0 self,
        _env: Env,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn get_id(&self) -> &str { ... }
}

Required Methods§

Source

fn up<'life0, 'async_trait>( &'life0 self, env: Env, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs a migration.

Provided Methods§

Source

fn down<'life0, 'async_trait>( &'life0 self, _env: Env, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Rollbacks a migration. Since not every migration could be rollbacked and it often happens there is a blank implementation

Source

fn get_id(&self) -> &str

A status about a migration will be stored in a db collection with the following document id We can pass an id manually otherwise it will be based on the type name so that uniqueness per project is guaranteed out of the box

Implementors§