Skip to main content

migrate

Function migrate 

Source
pub async fn migrate(
    pool: &PgPool,
    options: MigrateOptions<'_>,
) -> Result<(), MigrateError>
Expand description

Applies Reliar’s migrations. Never invoked implicitly (SRS §35).

Creates options.schema if it does not exist, keeps bookkeeping in <schema>._migrations — never _sqlx_migrations — and serializes concurrent callers with an advisory lock, so every caller after the first observes Ok(()). Idempotent. Self-contained: does not depend on the caller’s search_path (ADR 0018) — create_schema plus the qualified bookkeeping table name make it work over a pool whose URL never set one.

§Errors

Returns MigrateError::InvalidSchema when options.schema is not a valid PostgreSQL identifier, or MigrateError::Sqlx for a connection failure, a checksum mismatch against an already applied file, or any other failure sqlx::migrate::Migrator::run reports.