Skip to main content

run

Function run 

Source
pub async fn run<Context: Sync>(
    migrator: Migrator,
    pool: &PgPool,
    steps: &[Step<Context>],
    context: &Context,
) -> Result<(), OperationOutcomeError>
Expand description

Applies the migrations of migrator that the database of pool lacks, in version order, each with its step if it has one. context is what the steps are given.

The run holds sqlx’s migration lock for the database from start to end, so runs that start together take turns, steps included. It holds the lock on one connection and applies on another, so pool has to allow CONNECTIONS.

§Errors

Returns an error, before applying anything, if a step is given for a version that has no migration, for a version twice, or for a migration that runs outside of a transaction (-- no-transaction). Returns an error if a migration or a step fails, after applying what came before it.