add setup command

This commit is contained in:
Namekuji 2023-08-17 03:05:24 -04:00
parent 466c4e5636
commit 9d60a9701a
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532

View file

@ -4,6 +4,7 @@ use std::{fs, path::PathBuf};
use crate::config::Config;
use crate::error::Error;
use crate::migrator::Migrator;
use crate::setup::Initializer;
pub async fn run_cli() -> Result<(), Error> {
let cli = Cli::parse();
@ -29,7 +30,10 @@ pub async fn run_cli() -> Result<(), Error> {
match cli.subcommand {
MigrationCommand::Up { num } => {
Migrator::new(migration_dir, &scylla_conf).await?.up(num).await?
Migrator::new(migration_dir, &scylla_conf)
.await?
.up(num)
.await?
}
MigrationCommand::Down { num } => {
Migrator::new(migration_dir, &scylla_conf)
@ -37,6 +41,10 @@ pub async fn run_cli() -> Result<(), Error> {
.down(num)
.await?
}
MigrationCommand::Setup => {
let initializer = Initializer::new(&scylla_conf, &config.db).await?;
initializer.setup().await?;
}
_ => {}
};