use sqlx::sqlite::{SqlitePool, SqlitePoolOptions}; pub type DbPool = SqlitePool; /// Connect and run migrations. In-memory URLs get a single connection so the schema persists. pub async fn connect(url: &str) -> anyhow::Result { let in_memory = url.contains(":memory:"); let pool = SqlitePoolOptions::new() .max_connections(if in_memory { 1 } else { 5 }) .connect(url) .await?; sqlx::query("PRAGMA foreign_keys = ON") .execute(&pool) .await?; sqlx::migrate!("./migrations").run(&pool).await?; Ok(pool) }