pub async fn force_version(&mut self, version: u64) -> Result<MigrationSummary, Error> {
        self.local_migration(version)?;

        self.conn.ensure_migrations_table(&self.table).await?;

        let db_migrations = self.conn.list_migrations(&self.table).await?;

        let migrations = self
            .migrations
            .iter()
            .enumerate()
            .take_while(|(idx, _)| *idx < version as usize);

        self.conn.clear_migrations(&self.table).await?;

        let mut tx = self.conn.begin().await?;

        for (idx, mig) in migrations {
            DB::Connection::add_migration(
                &self.table,
                AppliedMigration {
                    version: idx as u64 + 1,
                    name: mig.name.clone(),
                    checksum: mig.checksum.clone(),
                    execution_time: Duration::default(),
                },
                &mut tx,
            )
            .await?;

            tracing::info!(
                version = idx + 1,
                name = %mig.name,
                "migration forcibly set as applied"
            );
        }

        tracing::info!("committing changes");
        tx.commit().await?;

        Ok(MigrationSummary {
            old_version: if db_migrations.is_empty() {
                None
            } else {
                Some(db_migrations.len() as _)
            },
            new_version: Some(version),
        })
    }
/// Forcibly set a given migration version in the database.
/// No migrations will be applied or reverted.
///
/// This function should be considered (almost) idempotent, and repeatedly calling it
/// should result in the same state. Some database-specific values can change, such as timestamps.
///
/// # Errors
///
/// The forced migration version must exist locally.
///
/// Connection and database errors are returned.
///
/// Truncating the migrations table and applying migrations are done
/// in separate transactions. As a consequence in some occasions
/// the migrations table might be cleared and no migrations will be set.
Forcibly set a given migration version in the database.
No migrations will be applied or reverted.

This function should be considered (almost) idempotent, and repeatedly calling it
should result in the same state. Some database-specific values can change, such as timestamps.
Forcibly set a given migration version in the database . No migrations will be applied or reverted . This function should be considered ( almost ) idempotent and repeatedly calling it should result in the same state . Some database - specific values can change such as timestamps .
pub async fn force_version(&mut self, version: u64) -> Result<MigrationSummary, Error> {
        self.local_migration(version)?;
        self.conn.ensure_migrations_table(&self.table).await?;
        let db_migrations = self.conn.list_migrations(&self.table).await?;
        let migrations = self
            .migrations
            .iter()
            .enumerate()
            .take_while(|(idx, _)| *idx < version as usize);
        self.conn.clear_migrations(&self.table).await?;
        let mut tx = self.conn.begin().await?;
        for (idx, mig) in migrations {
            DB::Connection::add_migration(
                &self.table,
                AppliedMigration {
                    version: idx as u64 + 1,
                    name: mig.name.clone(),
                    checksum: mig.checksum.clone(),
                    execution_time: Duration::default(),
                },
                &mut tx,
            )
            .await?;
            tracing::info!(
                version = idx + 1,
                name = %mig.name,
                "migration forcibly set as applied"
            );
        }
        tracing::info!("committing changes");
        tx.commit().await?;
        Ok(MigrationSummary {
            old_version: if db_migrations.is_empty() {
                None
            } else {
                Some(db_migrations.len() as _)
            },
            new_version: Some(version),
        })
    }
pub async fn force_version ( & mut self , version : u64 ) -> Result < MigrationSummary , Error > { self . local_migration ( version ) ? ; self . conn . ensure_migrations_table ( & self . table ) . await ? ; let db_migrations = self . conn . list_migrations ( & self . table ) . await ? ; let migrations = self . migrations . iter ( ) . enumerate ( ) . take_while ( | ( idx , _ ) | * idx < version as usize ) ; self . conn . clear_migrations ( & self . table ) . await ? ; let mut tx = self . conn . begin ( ) . await ? ; for ( idx , mig ) in migrations { DB :: Connection :: add_migration ( & self . table , AppliedMigration { version : idx as u64 + 1 , name : mig . name . clone ( ) , checksum : mig . checksum . clone ( ) , execution_time : Duration :: default ( ) , } , & mut tx , ) . await ? ; tracing :: info ! ( version idx 1 name mig name " " ) ; } tracing :: info ! ( " " ) ; tx . commit ( ) . await ? ; Ok ( MigrationSummary { old_version : if db_migrations . is_empty ( ) { None } else { Some ( db_migrations . len ( ) as _ ) } , new_version : Some ( version ) , } ) }
Forcibly set a given migration version in the database.
Forcibly set a given migration version in the database .
&mut self
version
u64
&mut self
version
u64
errors
The forced migration version must exist locally.

Connection and database errors are returned.

Truncating the migrations table and applying migrations are done
in separate transactions. As a consequence in some occasions
the migrations table might be cleared and no migrations will be set.
The forced migration version must exist locally . Connection and database errors are returned . Truncating the migrations table and applying migrations are done in separate transactions . As a consequence in some occasions the migrations table might be cleared and no migrations will be set .