Migrator

Struct Migrator 

Source
pub struct Migrator<T: Adapter> { /* private fields */ }
Expand description

Primary schemer type for defining and applying migrations.

Implementations§

Source§

impl<T: Adapter> Migrator<T>

Source

pub fn new(adapter: T) -> Migrator<T>

Create a Migrator using the given Adapter.

Source

pub fn register( &mut self, migration: Box<T::MigrationType>, ) -> Result<(), MigratorError<T::Error>>

Register a migration into the dependency graph.

Source

pub fn register_multiple( &mut self, migrations: Vec<Box<T::MigrationType>>, ) -> Result<(), MigratorError<T::Error>>

Register multiple migrations into the dependency graph. The Vec does not need to be order by dependency structure.

Source

pub fn up(&mut self, to: Option<Uuid>) -> Result<(), MigratorError<T::Error>>

Apply migrations as necessary to so that the specified migration is applied (inclusive).

If to is None, apply all registered migrations.

Source

pub fn down(&mut self, to: Option<Uuid>) -> Result<(), MigratorError<T::Error>>

Revert migrations as necessary so that no migrations dependent on the specified migration are applied. If the specified migration was already applied, it will still be applied.

If to is None, revert all applied migrations.

Auto Trait Implementations§

§

impl<T> Freeze for Migrator<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Migrator<T>

§

impl<T> Send for Migrator<T>
where T: Send, <T as Adapter>::MigrationType: Send,

§

impl<T> Sync for Migrator<T>
where T: Sync, <T as Adapter>::MigrationType: Sync,

§

impl<T> Unpin for Migrator<T>
where T: Unpin,

§

impl<T> UnwindSafe for Migrator<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.