Skip to main content

Migration

Trait Migration 

Source
pub trait Migration: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn up<'a>(
        &'a self,
        schema: &'a Schema<'a>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
    fn down<'a>(
        &'a self,
        schema: &'a Schema<'a>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
}
Expand description

One migration.

name must be unique and sortable — the generator produces 2026_08_29_000001_create_users_table, so lexical order is time order.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn up<'a>( &'a self, schema: &'a Schema<'a>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Apply the change.

Source

fn down<'a>( &'a self, schema: &'a Schema<'a>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Undo it. A migration that cannot be undone should say so by returning an error, rather than silently doing nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§