Trait diesel_migrations::MigrationHarness
source · 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