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
impl Runner
sourcepub fn get_migrations(&self) -> &Vec<Migration, Global>
pub fn get_migrations(&self) -> &Vec<Migration, Global>
Get the gathered migrations.
sourcepub fn set_target(self, target: Target) -> Runner
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
sourcepub fn set_grouped(self, grouped: bool) -> Runner
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).
sourcepub fn set_abort_divergent(self, abort_divergent: bool) -> Runner
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
sourcepub fn set_abort_missing(self, abort_missing: bool) -> Runner
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
sourcepub fn get_last_applied_migration<C>(
&self,
conn: &mut C
) -> Result<Option<Migration>, Error>where
C: Migrate,
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
sourcepub async fn get_last_applied_migration_async<C>(
&self,
conn: &mut C
) -> impl Future<Output = Result<Option<Migration>, Error>>where
C: AsyncMigrate + Send,
pub async fn get_last_applied_migration_async<C>( &self, conn: &mut C ) -> impl Future<Output = 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
sourcepub fn get_applied_migrations<C>(
&self,
conn: &mut C
) -> Result<Vec<Migration, Global>, Error>where
C: Migrate,
pub fn get_applied_migrations<C>( &self, conn: &mut C ) -> Result<Vec<Migration, Global>, Error>where C: Migrate,
Queries the database for all previous applied migrations
sourcepub async fn get_applied_migrations_async<C>(
&self,
conn: &mut C
) -> impl Future<Output = Result<Vec<Migration, Global>, Error>>where
C: AsyncMigrate + Send,
pub async fn get_applied_migrations_async<C>( &self, conn: &mut C ) -> impl Future<Output = Result<Vec<Migration, Global>, Error>>where C: AsyncMigrate + Send,
Queries the database asynchronously for all previous applied migrations
sourcepub fn set_migration_table_name<S>(
&mut self,
migration_table_name: S
) -> &mut Runnerwhere
S: AsRef<str>,
pub fn set_migration_table_name<S>( &mut self, migration_table_name: S ) -> &mut Runnerwhere 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