feat: speed up DB migrations sub cmd

This commit is contained in:
Aravinth Manivannan 2022-09-21 18:01:04 +05:30
parent 7a8808f95c
commit d994400ff1
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -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(())
}