Skip to content

Commit

Permalink
Update src/db.rs
Browse files Browse the repository at this point in the history
LGTM

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
arkanoider and coderabbitai[bot] authored Jan 3, 2025
1 parent d29f20e commit 66bbd9c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub async fn connect() -> Result<Pool<Sqlite>> {
match sqlx::migrate!().run(&pool).await {
Ok(_) => (),
Err(e) => {
// Clean up the created file on migration failure
if let Err(cleanup_err) = std::fs::remove_file(db_path) {
tracing::warn!("Failed to clean up db file: {}", cleanup_err);
}
return Err(anyhow::anyhow!("Failed to run migrations: {}", e));
}
}
Expand Down

0 comments on commit 66bbd9c

Please sign in to comment.