pub trait MigrationHarness<DB: Backend> {
// Required methods
fn run_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>>;
fn revert_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>>;
fn applied_migrations(&mut self) -> Result<Vec<MigrationVersion<'static>>>;
// Provided methods
fn has_pending_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<bool> { ... }
fn run_pending_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>> { ... }
fn run_next_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>> { ... }
fn revert_all_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>> { ... }
fn revert_last_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<MigrationVersion<'static>> { ... }
fn pending_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<Box<dyn Migration<DB>>>> { ... }
}
Expand description
A migration harness is an entity which applies migration to an existing database
Required Methods§
Sourcefn run_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>>
fn run_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>>
Apply a single migration
Types implementing this trait should call Migration::run
internally and record
that a specific migration version was executed afterwards.
Sourcefn revert_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>>
fn revert_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>>
Revert a single migration
Types implementing this trait should call Migration::revert
internally
and record that a specific migration version was reverted afterwards.
Sourcefn applied_migrations(&mut self) -> Result<Vec<MigrationVersion<'static>>>
fn applied_migrations(&mut self) -> Result<Vec<MigrationVersion<'static>>>
Get a list of already applied migration versions
Provided Methods§
Sourcefn has_pending_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<bool>
fn has_pending_migration<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<bool>
Checks if the database represented by the current harness has unapplied migrations
Sourcefn run_pending_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>>
fn run_pending_migrations<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<Vec<MigrationVersion<'_>>>
Execute all unapplied migrations for a given migration source
Sourcefn run_next_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>>
fn run_next_migration<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<MigrationVersion<'_>>
Execute the next migration from the given migration source
Sourcefn revert_all_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>>
fn revert_all_migrations<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<Vec<MigrationVersion<'_>>>
Revert all applied migrations from a given migration source
Sourcefn revert_last_migration<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<MigrationVersion<'static>>
fn revert_last_migration<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<MigrationVersion<'static>>
Revert the last migration from a given migration source
This method returns a error if the given migration source does not contain the last applied migration
Sourcefn pending_migrations<S: MigrationSource<DB>>(
&mut self,
source: S,
) -> Result<Vec<Box<dyn Migration<DB>>>>
fn pending_migrations<S: MigrationSource<DB>>( &mut self, source: S, ) -> Result<Vec<Box<dyn Migration<DB>>>>
Get a list of non applied migrations for a specific migration source
The returned migration list is sorted in ascending order by the individual version of each migration
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.