-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added more logging information to the db
- Loading branch information
1 parent
108e6a9
commit 9409730
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |