From 590a3736c4f81212871d8de835098eb9471724e3 Mon Sep 17 00:00:00 2001 From: aumetra Date: Mon, 2 Oct 2023 16:51:33 +0200 Subject: [PATCH] move pool construction after blocking task --- crates/kitsune-db/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/kitsune-db/src/lib.rs b/crates/kitsune-db/src/lib.rs index f5e9a0072..8df0eccb2 100644 --- a/crates/kitsune-db/src/lib.rs +++ b/crates/kitsune-db/src/lib.rs @@ -39,12 +39,6 @@ pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); pub async fn connect(conn_str: &str, max_pool_size: usize) -> Result { LogTracer::init().ok(); - let config = AsyncDieselConnectionManager::::new(conn_str); - let pool = Pool::builder(config) - .max_size(max_pool_size) - .build() - .unwrap(); - tokio::task::spawn_blocking({ let conn_str = conn_str.to_string(); @@ -61,7 +55,14 @@ pub async fn connect(conn_str: &str, max_pool_size: usize) -> Result { }) .await??; + let config = AsyncDieselConnectionManager::::new(conn_str); + let pool = Pool::builder(config) + .max_size(max_pool_size) + .build() + .unwrap(); + let mut conn = pool.get().await?; + kitsune_language::generate_postgres_enum(&mut conn, "language_iso_code").await?; kitsune_language::generate_regconfig_function( &mut conn,