allow drop db when migration was modified
This commit is contained in:
parent
9b1e75b62a
commit
1e5c523df9
@ -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<Sqlite>) -> Result<&'static str, Box<dyn std::error::Error>> {
|
||||
if let Err(e) = sqlx::migrate!("../migrations").run(conn).await {
|
||||
panic!("{e}");
|
||||
}
|
||||
pub async fn db_migrate(conn: &Pool<Sqlite>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<Sqlite>) -> Result<&'static str, Box<dyn std
|
||||
sqlx::query(query).bind(secret).execute(conn).await?;
|
||||
}
|
||||
|
||||
Ok("Database migrated!")
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn select_global(conn: &Pool<Sqlite>) -> Result<GlobalSettings, sqlx::Error> {
|
||||
|
@ -206,7 +206,7 @@ fn global_user(args: &mut Args) {
|
||||
pub async fn run_args(pool: &Pool<Sqlite>) -> 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}");
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user