diff --git a/Cargo.lock b/Cargo.lock index f110bd1..0d9be2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1069,7 +1069,7 @@ dependencies = [ [[package]] name = "crosup" -version = "0.4.6" +version = "0.4.7" dependencies = [ "anyhow", "clap 3.2.25", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 2123b5e..0237284 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "crosup" readme = "../../README.md" repository = "https://github.com/tsirysndr/crosup" -version = "0.4.6" +version = "0.4.7" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/cli/src/cmd/add.rs b/crates/cli/src/cmd/add.rs index 074965c..ebdd148 100644 --- a/crates/cli/src/cmd/add.rs +++ b/crates/cli/src/cmd/add.rs @@ -10,8 +10,6 @@ use crate::{cmd::print_diff, macros::install, types::InstallArgs}; pub async fn execute_add(tools: Vec, ask: bool) -> Result<(), Error> { let (mut current_config, filename, content, is_present) = verify_if_config_file_is_present()?; - migration::run().await; - current_config.packages = match current_config.packages { Some(ref mut packages) => { tools.iter().for_each(|x| { diff --git a/crates/cli/src/cmd/diff.rs b/crates/cli/src/cmd/diff.rs index c765a5e..35b2383 100644 --- a/crates/cli/src/cmd/diff.rs +++ b/crates/cli/src/cmd/diff.rs @@ -1,6 +1,7 @@ use anyhow::Error; use crosup_core::config::verify_if_config_file_is_present; use crosup_repo::{file::FileRepo, modification::ModificationRepo}; +use migration::MigratorTrait; use owo_colors::OwoColorize; use sea_orm::DatabaseConnection; @@ -11,9 +12,8 @@ use super::get_database_connection; pub async fn execute_diff() -> Result<(), Error> { let (_, filename, content, _) = verify_if_config_file_is_present()?; - migration::run().await; - let db: DatabaseConnection = get_database_connection().await?; + migration::Migrator::up(&db, None).await?; let current_dir = std::env::current_dir()?; let path = format!("{}/{}", current_dir.display(), filename); diff --git a/crates/cli/src/cmd/history.rs b/crates/cli/src/cmd/history.rs index d0d5310..82e2dfa 100644 --- a/crates/cli/src/cmd/history.rs +++ b/crates/cli/src/cmd/history.rs @@ -5,16 +5,17 @@ use anyhow::Error; use crosup_core::config::verify_if_config_file_is_present; use crosup_repo::{file::FileRepo, modification::ModificationRepo}; use crosup_tui::{history::display_history, App}; +use migration::MigratorTrait; use owo_colors::OwoColorize; use sea_orm::DatabaseConnection; pub async fn execute_history() -> Result<(), Error> { let (_, filename, _, _) = verify_if_config_file_is_present()?; - migration::run().await; - let db: DatabaseConnection = get_database_connection().await?; + migration::Migrator::up(&db, None).await?; + let current_dir = std::env::current_dir()?; let path = format!("{}/{}", current_dir.display(), filename); diff --git a/crates/cli/src/cmd/install.rs b/crates/cli/src/cmd/install.rs index 46276f4..bec7d6e 100644 --- a/crates/cli/src/cmd/install.rs +++ b/crates/cli/src/cmd/install.rs @@ -6,6 +6,7 @@ use crosup_core::{ use crosup_repo::{file::FileRepo, modification::ModificationRepo}; use crosup_ssh::setup_ssh_connection; use crosup_types::configuration::Configuration; +use migration::MigratorTrait; use owo_colors::OwoColorize; use sea_orm::{Database, DatabaseConnection}; use ssh2::Session; @@ -15,8 +16,6 @@ use crate::{macros::install, types::InstallArgs}; pub async fn execute_install(args: InstallArgs) -> Result<(), Error> { let (config, filename, content, _) = verify_if_config_file_is_present()?; - migration::run().await; - let mut config = match args.tools.clone() { Some(packages) => Configuration { packages: Some(packages), @@ -81,6 +80,8 @@ pub async fn execute_install(args: InstallArgs) -> Result<(), Error> { let db: DatabaseConnection = Database::connect(&database_url).await?; + migration::Migrator::up(&db, None).await?; + let current_dir = std::env::current_dir()?; let path = format!("{}/{}", current_dir.display(), filename);