Skip to main content

migrate

Function migrate 

Source
pub fn migrate(conn: &mut Connection, migrations: &[&str]) -> Result<()>
Expand description

Apply migrations[user_version..] in order, each in its own transaction. Refuses to run against a database newer than this binary.

Each step reads the version inside its transaction, which holds the write lock from its start: IMMEDIATE, asked for here rather than left to the connection’s default (configure sets it; a plain connection does not). Another connection migrating the same file meanwhile has either committed the step, and it is skipped, or not begun it. A version read before the lock could be stale by then, and the step would run twice.