use anyhow::Result; use sqlx::{sqlite::SqlitePoolOptions, SqlitePool}; pub async fn create_pool(database_url: &str) -> Result { let pool = SqlitePoolOptions::new() .max_connections(5) .connect(database_url) .await?; Ok(pool) } pub async fn run_migrations(pool: &SqlitePool) -> Result<()> { sqlx::query( r#" CREATE TABLE IF NOT EXISTS tasks ( id TEXT PRIMARY KEY NOT NULL, title TEXT NOT NULL, description TEXT, completed BOOLEAN NOT NULL DEFAULT 0, created_at INTEGER NOT NULL ) "#, ) .execute(pool) .await?; Ok(()) }