with_migration_lock

Function with_migration_lock 

Source
pub async fn with_migration_lock<T, F>(
    database: &DatabaseConnection,
    options: &MigrationLockOptions,
    operation: F,
) -> Result<T, DbErr>
where F: for<'a> FnOnce(DatabaseExecutor<'a>) -> MigrationFuture<'a, T>,
Expand description

Runs a product migration callback while holding the backend’s process-wide migration lock.

PostgreSQL uses a transaction-scoped advisory lock. MySQL uses a dedicated single-connection pool and a connection-bound named lock without wrapping DDL in a transaction. SQLite runs the callback in a transaction without an additional external lock.

§Errors

Returns an error when lock options are invalid, the backend is unsupported, connection, transaction, or lock operations fail, the callback fails, or transactional finalization fails.