Add sql transactions

This commit is contained in:
Tobias Reisinger 2024-05-02 13:30:14 +02:00
parent 455ca50695
commit 9823511b62
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
9 changed files with 171 additions and 138 deletions

View file

@ -28,11 +28,11 @@ async fn main() -> Result<(), std::io::Error> {
let pool = emgauwa_common::db::init(&settings.database).await?;
let mut conn = pool.acquire().await.map_err(EmgauwaError::from)?;
DbController::all_inactive(&mut conn)
let mut tx = pool.begin().await.map_err(EmgauwaError::from)?;
DbController::all_inactive(&mut tx)
.await
.map_err(EmgauwaError::from)?;
conn.close().await.map_err(EmgauwaError::from)?;
tx.commit().await.map_err(EmgauwaError::from)?;
let app_state_arbiter = Arbiter::with_tokio_rt(|| {
tokio::runtime::Builder::new_multi_thread()