use refinery::config::{Config, ConfigDbType}; use sqlx::sqlite::SqliteConnectOptions; use sqlx::ConnectOptions; use std::str::FromStr; pub mod migrations; pub(crate) async fn migrate() -> Result<(), Box> { //Create database if missing. let conn = SqliteConnectOptions::from_str("sqlite://tenebrous.sqlite")? .create_if_missing(true) .connect() .await?; drop(conn); let mut conn = Config::new(ConfigDbType::Sqlite).set_db_path("tenebrous.sqlite"); println!("Running migrations"); migrations::runner().run(&mut conn)?; Ok(()) }