Skip to content

Commit

Permalink
feat: refuse to start when no database is configured
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisaAkiron committed Mar 8, 2024
1 parent 348bc3c commit 58fd932
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/configs/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ pub struct Database {

impl PreflightCheck for Database {
async fn preflight_check(&self) -> Result<(), String> {
match &self.postgresql {
Some(postgresql) => postgresql.preflight_check().await,
let mut empty = true;

let result = match &self.postgresql {
Some(postgresql) => {
empty = false;
postgresql.preflight_check().await
}
None => Ok(()),
};

if empty {
Err("No database configuration found".to_string())
} else {
result
}
}
}

0 comments on commit 58fd932

Please sign in to comment.