Function hyper_scripter_historian::migration::do_migrate
source · Examples found in repository?
More examples
src/db.rs (line 18)
11 12 13 14 15 16 17 18 19 20 21 22 23
pub async fn get_pool(dir_path: impl AsRef<Path>) -> Result<SqlitePool, sqlx::error::Error> {
let file = get_file(dir_path);
let opt = SqliteConnectOptions::new()
.filename(&file)
.journal_mode(SqliteJournalMode::Off);
let res = SqlitePool::connect_with(opt).await;
let pool = if res.is_err() {
crate::migration::do_migrate(file).await?
} else {
res?
};
Ok(pool)
}