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 acquires a session advisory lock without opening a waiting transaction;
the callback is transactional unless explicitly disabled in the options. MySQL
uses a dedicated session and named lock without a DDL 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.