Skip to main content

Migration

Trait Migration 

Source
pub trait Migration: Send + Sync {
    // Required method
    fn up(&self) -> Schema;

    // Provided methods
    fn down(&self) -> Option<Schema> { ... }
    fn transactional(&self) -> bool { ... }
}
Expand description

A single schema change.

Required Methods§

Source

fn up(&self) -> Schema

Statements that apply the migration.

Provided Methods§

Source

fn down(&self) -> Option<Schema>

Statements that revert up, or None when the change cannot be reversed safely (for example, dropping a table loses its data).

A batch containing an irreversible migration is never rolled back.

Source

fn transactional(&self) -> bool

Whether to wrap the migration in a transaction. Defaults to true.

Opt out only for statements that cannot run inside a transaction; if a non-transactional migration fails, earlier statements may remain applied.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§