pub struct MigrationRunner {
pub history: Mutex<Vec<MigrationRecord>>,
pub current_version: AtomicU32,
pub stats: MigrationStats,
}Expand description
Executes migration plans and tracks history.
All mutation is performed through shared references so that the runner can be
wrapped in an Arc and used from multiple threads.
Fields§
§history: Mutex<Vec<MigrationRecord>>Full history of every step that has been executed.
current_version: AtomicU32Current schema version, updated atomically after each successful step.
stats: MigrationStatsCumulative statistics.
Implementations§
Source§impl MigrationRunner
impl MigrationRunner
Sourcepub fn new(initial_version: SchemaVersion) -> Self
pub fn new(initial_version: SchemaVersion) -> Self
Create a runner starting at initial_version.
Sourcepub fn execute_step(
&self,
step: &MigrationStep,
blocks_count: u64,
) -> Result<MigrationRecord, MigrationError>
pub fn execute_step( &self, step: &MigrationStep, blocks_count: u64, ) -> Result<MigrationRecord, MigrationError>
Execute a single migration step (no actual I/O — simulates the step).
Records the outcome in the history log and updates statistics.
Sourcepub fn execute_plan(
&self,
plan: &MigrationPlan,
blocks_per_step: u64,
) -> Result<Vec<MigrationRecord>, MigrationError>
pub fn execute_plan( &self, plan: &MigrationPlan, blocks_per_step: u64, ) -> Result<Vec<MigrationRecord>, MigrationError>
Execute every step in a MigrationPlan sequentially.
Returns the list of completed MigrationRecords. If any step fails the
error is returned immediately and subsequent steps are not executed.
Sourcepub fn current_version(&self) -> SchemaVersion
pub fn current_version(&self) -> SchemaVersion
Return the current schema version.
Sourcepub fn history(&self) -> Vec<MigrationRecord>
pub fn history(&self) -> Vec<MigrationRecord>
Return a clone of the full history.
Sourcepub fn can_rollback(&self) -> bool
pub fn can_rollback(&self) -> bool
Returns true when the most recent step was reversible and can be rolled back.
Auto Trait Implementations§
impl !Freeze for MigrationRunner
impl RefUnwindSafe for MigrationRunner
impl Send for MigrationRunner
impl Sync for MigrationRunner
impl Unpin for MigrationRunner
impl UnsafeUnpin for MigrationRunner
impl UnwindSafe for MigrationRunner
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more