From a284e93ae79354a071f23113af916e0b3c89cd47 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 20 Sep 2024 23:30:47 -0400 Subject: Put database prep somewhere tests can call it. --- src/cli.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 9d0606d..729a791 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,12 +1,11 @@ use std::io; -use std::str::FromStr; use axum::{middleware, Router}; use clap::Parser; -use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions}; +use sqlx::sqlite::SqlitePool; use tokio::net; -use crate::{app::App, channel, clock, events, login}; +use crate::{app::App, channel, clock, events, login, repo::pool}; pub type Result = std::result::Result; @@ -26,8 +25,6 @@ impl Args { pub async fn run(self) -> Result<()> { let pool = self.pool().await?; - sqlx::migrate!().run(&pool).await?; - let app = App::from(pool).await?; let app = routers() .route_layer(middleware::from_fn(clock::middleware)) @@ -54,12 +51,7 @@ impl Args { } async fn pool(&self) -> sqlx::Result { - let options = SqliteConnectOptions::from_str(&self.database_url)? - .create_if_missing(true) - .optimize_on_close(true, /* analysis_limit */ None); - - let pool = SqlitePoolOptions::new().connect_with(options).await?; - Ok(pool) + pool::prepare(&self.database_url).await } } -- cgit v1.2.3