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>
impl<'m, 'c, MigContext, M: Metadata> Migratex<'m, 'c, MigContext, M>
Sourcepub fn new(
ctx: &'c mut MigContext,
meta: &'m mut M,
migrations: Vec<BoxMigration<MigContext>>,
) -> Self
pub fn new( ctx: &'c mut MigContext, meta: &'m mut M, migrations: Vec<BoxMigration<MigContext>>, ) -> Self
Create a new Migratex.
Sourcepub fn context(&self) -> &MigContext
pub fn context(&self) -> &MigContext
Get the migration context.
Sourcepub fn latest_version(&self) -> i32
pub fn latest_version(&self) -> i32
Get the most recent migration version.
Sourcepub async fn migrate_to_latest(&mut self) -> Result<()>
pub async fn migrate_to_latest(&mut self) -> Result<()>
Migrate from current metadata.version up to the latest migration version
Sourcepub async fn migrate_to_zero(&mut self) -> Result<()>
pub async fn migrate_to_zero(&mut self) -> Result<()>
Rollback everything (migrate to version 0, before the first migration).
Sourcepub async fn migrate_next(&mut self) -> Result<()>
pub async fn migrate_next(&mut self) -> Result<()>
Migrate to the next version (up)
Sourcepub async fn migrate_prev(&mut self) -> Result<()>
pub async fn migrate_prev(&mut self) -> Result<()>
Migrate to the previous version (down)
Sourcepub async fn migrate_to(&mut self, target: i32) -> Result<()>
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>
impl<'m, 'c, MigContext, M> Sync for Migratex<'m, 'c, MigContext, M>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more