Skip to main content

run_background

Function run_background 

Source
pub async fn run_background(
    pool: &PgPool,
    migrations: &[Background],
) -> Result<Option<Vec<String>>, Error>
Expand description

Run each of migrations not yet recorded, in order, outside any transaction, recording each once all its statements have run. One process at a time holds BACKGROUND_LOCK, so replicas booting together do not run one twice: a process that cannot take it answers None at once, and the one that holds it answers the names it ran. A failure stops the run, leaves that migration unrecorded, so the next run tries it again, and releases the lock.

ยงErrors

Fails on a name that is empty, too long, or used twice, on a database error, or on a statement that fails.