Skip to content

Commit

Permalink
added more logging information to the db
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Nov 13, 2023
1 parent 108e6a9 commit 9409730
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/main-api/src/setup/database/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
mod alias;
mod data;

use sqlx::{Executor, PgPool};
use log::info;
use sqlx::PgPool;

pub(crate) async fn setup_database(pool: &PgPool) -> Result<(), Box<dyn std::error::Error>> {
sqlx::migrate!("./migrations").run(pool).await?;
// this is to setup the database faster
// we don't want to use an acid compliant database for this step ;)
pool.execute("PRAGMA journal_mode = OFF;");
pool.execute("PRAGMA synchronous = OFF;");

// delete all old data
info!("database setup complete, deleting old data");
sqlx::query!("DELETE FROM aliases").execute(pool).await?;
sqlx::query!("DELETE FROM en").execute(pool).await?;
sqlx::query!("DELETE FROM de").execute(pool).await?;

info!("loading new data");
data::load_all_to_db(pool).await?;
info!("loading new aliases");
alias::load_all_to_db(pool).await?;
Ok(())
}

0 comments on commit 9409730

Please sign in to comment.