Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sqlx-core/src/migrate/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
5 changes: 4 additions & 1 deletion sqlx-mysql/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion sqlx-postgres/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion sqlx-sqlite/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading