From 1e5c523df95098f70d0a37cf379f934addd23ace Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Tue, 27 Aug 2024 12:37:32 +0200 Subject: [PATCH] allow drop db when migration was modified --- ffplayout/src/db/handles.rs | 8 +++----- ffplayout/src/utils/args_parse.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ffplayout/src/db/handles.rs b/ffplayout/src/db/handles.rs index 238e7856..d74e9270 100644 --- a/ffplayout/src/db/handles.rs +++ b/ffplayout/src/db/handles.rs @@ -11,10 +11,8 @@ use super::models::{AdvancedConfiguration, Configuration}; use crate::db::models::{Channel, GlobalSettings, Role, TextPreset, User}; use crate::utils::{advanced_config::AdvancedConfig, config::PlayoutConfig, local_utc_offset}; -pub async fn db_migrate(conn: &Pool) -> Result<&'static str, Box> { - if let Err(e) = sqlx::migrate!("../migrations").run(conn).await { - panic!("{e}"); - } +pub async fn db_migrate(conn: &Pool) -> Result<(), Box> { + sqlx::migrate!("../migrations").run(conn).await?; if select_global(conn).await.is_err() { let secret: String = rand::thread_rng() @@ -34,7 +32,7 @@ pub async fn db_migrate(conn: &Pool) -> Result<&'static str, Box) -> Result { diff --git a/ffplayout/src/utils/args_parse.rs b/ffplayout/src/utils/args_parse.rs index f281b772..7b9fc043 100644 --- a/ffplayout/src/utils/args_parse.rs +++ b/ffplayout/src/utils/args_parse.rs @@ -206,7 +206,7 @@ fn global_user(args: &mut Args) { pub async fn run_args(pool: &Pool) -> Result<(), i32> { let mut args = ARGS.clone(); - if args.dump_advanced.is_none() && args.dump_config.is_none() { + if args.dump_advanced.is_none() && args.dump_config.is_none() && !args.drop_db { if let Err(e) = handles::db_migrate(pool).await { panic!("{e}"); };