use std::process::exit; use sqlx::{Pool, Postgres, postgres::PgPoolOptions}; pub async fn init(db_url: &str) -> Pool { let db = match PgPoolOptions::new().connect(db_url).await { Ok(p) => p, Err(_) => { tracing::error!("Failed to connect to the database"); exit(1); } }; match sqlx::migrate!().run(&db).await { Ok(_) => tracing::info!("Migration completed succesfully"), Err(_) => { tracing::error!("Failed to apply migrations"); exit(1) } } db }