From d994400ff181f0372ce6403a60d1adba6d86b169 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Wed, 21 Sep 2022 18:01:04 +0530 Subject: [PATCH] feat: speed up DB migrations sub cmd --- src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 672fe8a..cbde008 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,13 +91,15 @@ async fn main() -> std::io::Result<()> { ); let settings = Settings::new().unwrap(); - settings.init(); - let ctx = Ctx::new(settings.clone()).await; - let ctx = actix_web::web::Data::new(ctx); match &cli.command { - Commands::Migrate => ctx.db.migrate().await.unwrap(), - Commands::Serve => serve(settings, ctx).await.unwrap(), + Commands::Migrate => db::get_db(&settings).await.migrate().await.unwrap(), + Commands::Serve => { + let ctx = Ctx::new(settings.clone()).await; + let ctx = actix_web::web::Data::new(ctx); + settings.init(); + serve(settings, ctx).await.unwrap(); + } } Ok(()) }