pub struct MigrationRunner<'a, Ctx, S>where
S: MigrationStore,{ /* private fields */ }Expand description
Runs migrations against a context using a store for tracking.
Generic parameters:
Ctx: The context passed to migrations (e.g., database connection)S: The store implementation for tracking applied migrations
Implementations§
Source§impl<'a, Ctx, S> MigrationRunner<'a, Ctx, S>where
S: MigrationStore,
impl<'a, Ctx, S> MigrationRunner<'a, Ctx, S>where
S: MigrationStore,
pub fn new(store: S) -> MigrationRunner<'a, Ctx, S>
Sourcepub fn into_store(self) -> S
pub fn into_store(self) -> S
Consume the runner and return the store
Sourcepub fn add<M>(self, migration: M) -> MigrationRunner<'a, Ctx, S>where
M: Migration<Ctx> + 'a,
pub fn add<M>(self, migration: M) -> MigrationRunner<'a, Ctx, S>where
M: Migration<Ctx> + 'a,
Add a migration
Sourcepub fn add_all<I, M>(self, migrations: I) -> MigrationRunner<'a, Ctx, S>where
I: IntoIterator<Item = M>,
M: Migration<Ctx> + 'a,
pub fn add_all<I, M>(self, migrations: I) -> MigrationRunner<'a, Ctx, S>where
I: IntoIterator<Item = M>,
M: Migration<Ctx> + 'a,
Add multiple migrations
Sourcepub fn current_version(&self) -> Result<u64, Error>
pub fn current_version(&self) -> Result<u64, Error>
Get current schema version
Sourcepub fn pending(&self) -> Result<Vec<&dyn Migration<Ctx>>, Error>
pub fn pending(&self) -> Result<Vec<&dyn Migration<Ctx>>, Error>
Get pending (unapplied) migrations
Sourcepub fn pending_phase(
&self,
phase: Phase,
) -> Result<Vec<&dyn Migration<Ctx>>, Error>
pub fn pending_phase( &self, phase: Phase, ) -> Result<Vec<&dyn Migration<Ctx>>, Error>
Get pending migrations for a specific phase
Sourcepub fn migrate_phase(
&mut self,
ctx: &mut Ctx,
phase: Phase,
) -> Result<usize, Error>
pub fn migrate_phase( &mut self, ctx: &mut Ctx, phase: Phase, ) -> Result<usize, Error>
Run pending migrations for a specific phase only
Sourcepub fn dry_run(&self) -> Result<DryRunResult, Error>
pub fn dry_run(&self) -> Result<DryRunResult, Error>
Dry-run: show what would be applied without actually applying
Sourcepub fn dry_run_phase(&self, phase: Phase) -> Result<DryRunResult, Error>
pub fn dry_run_phase(&self, phase: Phase) -> Result<DryRunResult, Error>
Dry-run for a specific phase
Auto Trait Implementations§
impl<'a, Ctx, S> Freeze for MigrationRunner<'a, Ctx, S>where
S: Freeze,
impl<'a, Ctx, S> !RefUnwindSafe for MigrationRunner<'a, Ctx, S>
impl<'a, Ctx, S> Send for MigrationRunner<'a, Ctx, S>where
S: Send,
impl<'a, Ctx, S> Sync for MigrationRunner<'a, Ctx, S>where
S: Sync,
impl<'a, Ctx, S> Unpin for MigrationRunner<'a, Ctx, S>where
S: Unpin,
impl<'a, Ctx, S> !UnwindSafe for MigrationRunner<'a, Ctx, S>
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