feat(database)!: switch from diesel to sea-orm

This commit is contained in:
2025-09-06 20:08:46 +04:00
parent e729d84c93
commit dbc800fef1
54 changed files with 2519 additions and 665 deletions

View File

@@ -7,20 +7,31 @@ pub(crate) mod tests {
pub fn test_env() {
info!("Loading test environment file...");
dotenvy::from_filename(".env.test.local")
.or_else(|_| dotenvy::from_filename(".env.test"))
.expect("Failed to load test environment file");
}
pub async fn test_app_state() -> web::Data<AppState> {
let state = new_app_state().await.unwrap();
let state = new_app_state(Some(static_app_state().await.get_database().clone()))
.await
.unwrap();
state.clone()
}
pub async fn static_app_state() -> web::Data<AppState> {
static STATE: OnceCell<web::Data<AppState>> = OnceCell::const_new();
STATE.get_or_init(|| test_app_state()).await.clone()
STATE
.get_or_init(async || -> web::Data<AppState> {
#[cfg(all(test, tokio_unstable))]
console_subscriber::init();
new_app_state(None).await.unwrap()
})
.await
.clone()
}
}