Skip to main content

max / makenotwork

417 B · 15 lines History Blame Raw
1 //! Database access. Connection comes from `ops_core::sqlite`; migrations are
2 //! per-crate (the `sqlx::migrate!` path is compile-time, relative to here).
3
4 use anyhow::Result;
5 use sqlx::SqlitePool;
6 use std::path::Path;
7
8 pub use ops_core::sqlite::connect;
9
10 pub async fn open(path: &Path) -> Result<SqlitePool> {
11 let pool = connect(path).await?;
12 sqlx::migrate!("./migrations").run(&pool).await?;
13 Ok(pool)
14 }
15