Add version information for failed cli migration (#3129) (#3130)

This commit is contained in:
Maciej Flak 2024-04-05 06:45:21 +02:00 committed by GitHub
parent 0aae849657
commit 45b5b61d7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View File

@ -6,6 +6,9 @@ pub enum MigrateError {
#[error("while executing migrations: {0}")]
Execute(#[from] Error),
#[error("while executing migration {1}: {0}")]
ExecuteMigration(#[source] Error, i64),
#[error("while resolving migrations: {0}")]
Source(#[source] BoxDynError),

View File

@ -199,7 +199,10 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
.execute(&mut *tx)
.await?;
let _ = tx.execute(&*migration.sql).await?;
let _ = tx
.execute(&*migration.sql)
.await
.map_err(|e| MigrateError::ExecuteMigration(e, migration.version))?;
// language=MySQL
let _ = query(

View File

@ -216,7 +216,10 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
// The `execution_time` however can only be measured for the whole transaction. This value _only_ exists for
// data lineage and debugging reasons, so it is not super important if it is lost. So we initialize it to -1
// and update it once the actual transaction completed.
let _ = tx.execute(&*migration.sql).await?;
let _ = tx
.execute(&*migration.sql)
.await
.map_err(|e| MigrateError::ExecuteMigration(e, migration.version))?;
// language=SQL
let _ = query(

View File

@ -142,7 +142,10 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
// The `execution_time` however can only be measured for the whole transaction. This value _only_ exists for
// data lineage and debugging reasons, so it is not super important if it is lost. So we initialize it to -1
// and update it once the actual transaction completed.
let _ = tx.execute(&*migration.sql).await?;
let _ = tx
.execute(&*migration.sql)
.await
.map_err(|e| MigrateError::ExecuteMigration(e, migration.version))?;
// language=SQL
let _ = query(