chore(ci): improve db migratiion to unserstand clash in CI

This commit is contained in:
Edouard Vanbelle
2026-06-19 14:37:02 +02:00
parent 14b63c9bd9
commit 55487187eb
2 changed files with 21 additions and 2 deletions
+20 -1
View File
@@ -200,6 +200,25 @@ async fn run_migrations(pool: &PgPool) -> Result<()> {
match sqlx::migrate!().run(pool).await {
Ok(()) => Ok(()),
Err(e) => Err(DbError(format!("Migration error: {}", e))),
Err(e) => Err(DbError(format_error_chain("Migration error", &e))),
}
}
/// Format an error and every wrapped `source()` cause on a single line.
///
/// sqlx's `MigrateError::Execute` wraps the underlying `sqlx::Error::Database`
/// which in turn carries the PG `DETAIL` (e.g. `Key (version)=(20260803000000)`
/// for a duplicate-key on `_sqlx_migrations_pkey`). The default `Display`
/// only renders the outermost layer, so the operationally-critical hint
/// gets buried. Walking the chain surfaces it without needing to bump
/// `RUST_LOG` to debug.
fn format_error_chain(prefix: &str, e: &(dyn std::error::Error + 'static)) -> String {
let mut out = format!("{prefix}: {e}");
let mut cur = e.source();
while let Some(c) = cur {
out.push_str(" -> ");
out.push_str(&c.to_string());
cur = c.source();
}
out
}
+1 -1
View File
@@ -18,7 +18,7 @@ OXICLOUD_OIDC_ENABLED=false
OXICLOUD_NEXTCLOUD_ENABLED=true
RUST_LOG="warn,audit=info"
RUST_LOG="warn,audit=info,sqlx::migrate=info"
#RUST_LOG=debug
#RUST_LOG=info