Skip to content

Commit

Permalink
fix: better logging on migration command (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
m30m authored Nov 7, 2024
1 parent 9a53bd9 commit 0c15612
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion auction-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ async fn create_pg_pool(database_url: &str) -> Result<PgPool> {

pub async fn run_migrations(migrate_options: MigrateOptions) -> Result<()> {
let pool = create_pg_pool(&migrate_options.database_url).await?;
if let Err(err) = migrate!("./migrations").run(&pool).await {
let migrator = migrate!("./migrations");
if let Err(err) = migrator.run(&pool).await {
match err {
sqlx::migrate::MigrateError::VersionMissing(version) => {
tracing::info!(
Expand All @@ -195,6 +196,13 @@ pub async fn run_migrations(migrate_options: MigrateOptions) -> Result<()> {
}
}
}
tracing::info!("Migrations ran successfully");
let last_migration_desc = migrator
.iter()
.last()
.map(|x| x.description.as_ref())
.unwrap_or("No migrations found");
tracing::info!("Last migration: {}", last_migration_desc);
Ok(())
}
pub async fn start_server(run_options: RunOptions) -> Result<()> {
Expand Down

0 comments on commit 0c15612

Please sign in to comment.