Running migrations.
This commit is contained in:
22
src/main.rs
22
src/main.rs
@@ -1,8 +1,12 @@
|
||||
use std::{env, fs::FileType};
|
||||
use sqlx::sqlite::SqliteConnectOptions;
|
||||
use sqlx::sqlite::SqlitePool;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use walkdir::DirEntry;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), sqlx::Error> {
|
||||
let mut args = env::args();
|
||||
let _program = args.next().expect("argv[0] should be this program?");
|
||||
let profile = args.next().expect("Must provide a profile");
|
||||
@@ -22,4 +26,18 @@ fn main() {
|
||||
for f in files {
|
||||
println!("{}", f.path().display());
|
||||
}
|
||||
|
||||
let db_path = dirs::home_dir()
|
||||
.map(|pb| pb.join(".record_watch.sqlite"))
|
||||
.unwrap();
|
||||
let url = format!("sqlite://{}", db_path.as_path().display());
|
||||
|
||||
println!("{}", &url);
|
||||
|
||||
let pool =
|
||||
SqlitePool::connect_with(SqliteConnectOptions::from_str(&url)?.create_if_missing(true))
|
||||
.await?;
|
||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user