Struct Migrator

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

Maintains an ordered collection of migrations to utilize.

Implementations§

Source§

impl<T: Adapter> Migrator<T>

Source

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

Create a migrator with a given adapter.

Source

pub fn adapter(&self) -> &T

Get a reference to the adapter.

Source

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

Register a migration. If a migration with the same version is already registered, a warning is logged and the registration fails.

Source

pub fn version_registered(&self, version: Version) -> bool

Returns true is a migration with the provided version has been registered.

Source

pub fn registered_versions(&self) -> BTreeSet<Version>

Returns the set of all registered migration versions.

Source

pub fn first_version(&self) -> Option<Version>

Returns the lowest version of the registered migrations, or None if no migrations have been registered.

Source

pub fn last_version(&self) -> Option<Version>

Returns the highest version of the registered migrations, or None if no migrations have been registered.

Source

pub fn current_version(&self) -> Result<Option<Version>, Error<T::Error>>

Returns the latest migration version, or None if no migrations have been recorded.

Source

pub fn migrated_versions(&self) -> Result<BTreeSet<Version>, Error<T::Error>>

Returns a set of the versions of all of the currently applied migrations.

Source

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

Rollback to the specified version (exclusive), or rollback to the state before any registered migrations were applied if None is specified.

Source

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

Migrate to the specified version (inclusive).

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.