Require DATABASE_URL to be set

This commit is contained in:
Imbus 2023-11-06 00:23:44 +01:00
parent b2095e98fb
commit 757e670dbb
3 changed files with 10 additions and 2 deletions

View file

@ -31,7 +31,11 @@ impl ServerState {
pub async fn new() -> Self {
// This is almost certainly bad practice for more reasons than I can count
dotenvy::dotenv().ok();
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
let db_url = dotenvy::var("DATABASE_URL").unwrap_or_else(|_| {
error!("DATABASE_URL not set in environment!");
std::process::exit(1);
});
info!("Using db_url: {}", &db_url);
if !sqlx::Sqlite::database_exists(&db_url).await.unwrap() {