pub trait Migration<DB, State = ()>: Send + Sync {
    // Required methods
    fn app(&self) -> &str;
    fn name(&self) -> &str;
    fn parents(&self) -> Vec<Box<dyn Migration<DB, State>>>;
    fn operations(&self) -> Vec<Box<dyn Operation<DB, State>>>;

    // Provided methods
    fn replaces(&self) -> Vec<Box<dyn Migration<DB, State>>> { ... }
    fn run_before(&self) -> Vec<Box<dyn Migration<DB, State>>> { ... }
    fn is_atomic(&self) -> bool { ... }
    fn is_virtual(&self) -> bool { ... }
}
Expand description

Trait for migration

Required Methods§

source

fn app(&self) -> &str

Migration app name. Can be name of folder or library where migration is located

source

fn name(&self) -> &str

Migration name. Can be file name without extension

source

fn parents(&self) -> Vec<Box<dyn Migration<DB, State>>>

Parents of migration (migrations that should be applied before this migration)

source

fn operations(&self) -> Vec<Box<dyn Operation<DB, State>>>

Operation performed for migration (create, drop, etc.). Migration can contains multiple operation within each other which are interrelated

Provided Methods§

source

fn replaces(&self) -> Vec<Box<dyn Migration<DB, State>>>

Replace certain migrations. If any one of listed migration is applied than migration will not be applied else migration will apply/revert instead of applying/reverting those migration.

source

fn run_before(&self) -> Vec<Box<dyn Migration<DB, State>>>

Run before(for applying)/after(for reverting) certain migration. This can be helpful in condition where other library migration need to be applied after this migration or reverted before this migration

source

fn is_atomic(&self) -> bool

Whether migration is atomic or not. By default it is atomic so this function returns true. If you make migration non atomic all its operation will be non atomic if any operation needs to be atomic it is recommended to split migration so one migration will have atomic operation where as another have non atomic operation

source

fn is_virtual(&self) -> bool

Whether migration is virtual or not. By default migration are not virtual. If migration is virtual than it expects another migration with same app and name present inside migration list which is not virtual. For virtual migration all other methods gets ignored since it is reference to actual migration instead of actual migration

Trait Implementations§

source§

impl<DB, State> Hash for dyn Migration<DB, State>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
source§

impl<DB, State> PartialEq for dyn Migration<DB, State>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<DB, State> Eq for dyn Migration<DB, State>

Implementations on Foreign Types§

source§

impl<DB, A, N> Migration<DB> for (A, N)
where A: AsRef<str> + Send + Sync, N: AsRef<str> + Send + Sync,

source§

fn app(&self) -> &str

source§

fn name(&self) -> &str

source§

fn parents(&self) -> Vec<Box<dyn Migration<DB, ()>>>

source§

fn operations(&self) -> Vec<Box<dyn Operation<DB, ()>>>

source§

fn is_virtual(&self) -> bool

Implementors§