mirror of
https://github.com/flibusta-apps/services_manager_server.git
synced 2026-03-03 15:10:54 +01:00
Run SQLx migrations at startup
Add an initial services table migration and enable the sqlx "migrate" feature. Introduce run_migrations in db.rs, run migrations on startup, and pass the PgPool into the router.
This commit is contained in:
@@ -13,7 +13,7 @@ use sqlx::PgPool;
|
||||
use tower_http::trace::{self, TraceLayer};
|
||||
use tracing::Level;
|
||||
|
||||
use crate::{config::CONFIG, db::get_pg_pool};
|
||||
use crate::config::CONFIG;
|
||||
|
||||
pub type Database = Extension<PgPool>;
|
||||
|
||||
@@ -218,9 +218,7 @@ async fn auth(req: Request<axum::body::Body>, next: Next) -> Result<Response, St
|
||||
Ok(next.run(req).await)
|
||||
}
|
||||
|
||||
pub async fn get_router() -> Router {
|
||||
let client = get_pg_pool().await;
|
||||
|
||||
pub async fn get_router(client: PgPool) -> Router {
|
||||
let (prometheus_layer, metric_handle) = PrometheusMetricLayer::pair();
|
||||
|
||||
let app_router = Router::new()
|
||||
|
||||
Reference in New Issue
Block a user