Migratex

Struct Migratex 

Source
pub struct Migratex<'m, 'c, MigContext, M: Metadata> { /* private fields */ }
Expand description

Migratex manages the migrations, this is the main struct. Think of it as a “migration manager”, “migrator”, “runner”). It can be used to migrate database / data / files / binaries, etc from one version to another.

Implementations§

Source§

impl<'m, 'c, MigContext, M: Metadata> Migratex<'m, 'c, MigContext, M>

Source

pub fn new( ctx: &'c mut MigContext, meta: &'m mut M, migrations: Vec<BoxMigration<MigContext>>, ) -> Self

Create a new Migratex.

Source

pub fn metadata(&self) -> &M

Get the current metadata.

Source

pub fn context(&self) -> &MigContext

Get the migration context.

Source

pub fn latest_version(&self) -> i32

Get the most recent migration version.

Source

pub async fn migrate_to_latest(&mut self) -> Result<()>

Migrate from current metadata.version up to the latest migration version

Source

pub async fn migrate_to_zero(&mut self) -> Result<()>

Rollback everything (migrate to version 0, before the first migration).

Source

pub async fn migrate_next(&mut self) -> Result<()>

Migrate to the next version (up)

Source

pub async fn migrate_prev(&mut self) -> Result<()>

Migrate to the previous version (down)

Source

pub async fn migrate_to(&mut self, target: i32) -> Result<()>

Migrate to a specific target version (up or down)

Auto Trait Implementations§

§

impl<'m, 'c, MigContext, M> Freeze for Migratex<'m, 'c, MigContext, M>

§

impl<'m, 'c, MigContext, M> !RefUnwindSafe for Migratex<'m, 'c, MigContext, M>

§

impl<'m, 'c, MigContext, M> Send for Migratex<'m, 'c, MigContext, M>
where MigContext: Send, M: Send,

§

impl<'m, 'c, MigContext, M> Sync for Migratex<'m, 'c, MigContext, M>
where MigContext: Sync, M: Sync,

§

impl<'m, 'c, MigContext, M> Unpin for Migratex<'m, 'c, MigContext, M>

§

impl<'m, 'c, MigContext, M> !UnwindSafe for Migratex<'m, 'c, MigContext, M>

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.