Skip to main content

migrate_pool

Function migrate_pool 

Source
pub async fn migrate_pool(
    pool: &Pool,
    dir: &Path,
) -> Result<Vec<Migration>, MigrateError>
Expand description

Apply every pending migration in dir against either backend. Each migration runs in its own transaction unless its atomic field is false (e.g. CREATE INDEX CONCURRENTLY, which neither PG nor MySQL allow inside a transaction).

Skips files already recorded in the ledger. Returns the migrations that were newly applied.

Concurrency caveat (batch 12): no advisory lock yet — peers running migrate_pool against the same DB simultaneously can both pass the applied_set check and try to apply the same file. The ledger PRIMARY KEY constraint catches the second writer’s INSERT and rolls its transaction back, but you’ll see noisy errors. Lock dispatch lands in batch 13.

§Errors

As migrate.