Struct refinery::Runner

source ·
pub struct Runner { /* private fields */ }
Expand description

Struct that represents the entrypoint to run the migrations, an instance of this struct is returned by the embed_migrations! macro. Runner should not need to be instantiated manually

Implementations§

source§

impl Runner

source

pub fn new(migrations: &[Migration]) -> Runner

instantiate a new Runner

source

pub fn get_migrations(&self) -> &Vec<Migration>

Get the gathered migrations.

source

pub fn set_target(self, target: Target) -> Runner

Set the target version up to which refinery should migrate, Latest migrates to the latest version available Version migrates to a user provided version, a Version with a higher version than the latest will be ignored, and Fake doesn’t actually run any migration, just creates and updates refinery’s schema migration table by default this is set to Latest

source

pub fn set_grouped(self, grouped: bool) -> Runner

Set true if all migrations should be grouped and run in a single transaction. by default this is set to false, each migration runs on their own transaction

§Note

set_grouped won’t probably work on MySQL Databases as MySQL lacks support for transactions around schema alteration operations, meaning that if a migration fails to apply you will have to manually unpick the changes in order to try again (it’s impossible to roll back to an earlier point).

source

pub fn set_abort_divergent(self, abort_divergent: bool) -> Runner

Set true if migration process should abort if divergent migrations are found i.e. applied migrations with the same version but different name or checksum from the ones on the filesystem. by default this is set to true

source

pub fn set_abort_missing(self, abort_missing: bool) -> Runner

Set true if migration process should abort if missing migrations are found i.e. applied migrations that are not found on the filesystem, or migrations found on filesystem with a version inferior to the last one applied but not applied. by default this is set to true

source

pub fn get_last_applied_migration<C>( &self, conn: &mut C ) -> Result<Option<Migration>, Error>
where C: Migrate,

Queries the database for the last applied migration, returns None if there aren’t applied Migrations

source

pub async fn get_last_applied_migration_async<C>( &self, conn: &mut C ) -> Result<Option<Migration>, Error>
where C: AsyncMigrate + Send,

Queries the database asynchronously for the last applied migration, returns None if there aren’t applied Migrations

source

pub fn get_applied_migrations<C>( &self, conn: &mut C ) -> Result<Vec<Migration>, Error>
where C: Migrate,

Queries the database for all previous applied migrations

source

pub async fn get_applied_migrations_async<C>( &self, conn: &mut C ) -> Result<Vec<Migration>, Error>
where C: AsyncMigrate + Send,

Queries the database asynchronously for all previous applied migrations

source

pub fn set_migration_table_name<S>( &mut self, migration_table_name: S ) -> &mut Runner
where S: AsRef<str>,

Set the table name to use for the migrations table. The default name is refinery_schema_history

§Warning

Changing this can be disastrous for your database. You should verify that the migrations table has the same name as the name you specify here, if this is changed on an existing project.

§Panics

If the provided migration_table_name is empty

source

pub fn run_iter<C>( self, connection: &mut C ) -> impl Iterator<Item = Result<Migration, Error>>
where C: Migrate,

Creates an iterator over pending migrations, applying each before returning the result from next(). If a migration fails, the iterator will return that result and further calls to next() will return None.

source

pub fn run<C>(&self, connection: &mut C) -> Result<Report, Error>
where C: Migrate,

Runs the Migrations in the supplied database connection

source

pub async fn run_async<C>(&self, connection: &mut C) -> Result<Report, Error>
where C: AsyncMigrate + Send,

Runs the Migrations asynchronously in the supplied database connection

Auto Trait Implementations§

§

impl Freeze for Runner

§

impl RefUnwindSafe for Runner

§

impl Send for Runner

§

impl Sync for Runner

§

impl Unpin for Runner

§

impl UnwindSafe for Runner

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.