dump_sqlite_schema/
dump-sqlite-schema.rs1use std::{fs, process};
7use std::path::PathBuf;
8
9fn main() {
10 let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
11
12 let tmp_file = root.join("tmp-bark-schema.sqlite");
13 if tmp_file.exists() != false {
14 fs::remove_file(&tmp_file).expect("failed to remove existing temporary db file");
15 }
16
17 bark::persist::sqlite::SqliteClient::open(tmp_file.clone())
18 .expect("error opening sqlite file");
19
20 let status = process::Command::new("sqlite3")
21 .arg(&tmp_file.display().to_string())
22 .arg(".schema")
23 .stdout(process::Stdio::inherit())
24 .spawn().unwrap()
25 .wait().unwrap()
26 .code().unwrap_or(1);
27
28 fs::remove_file(&tmp_file).expect("failed to remove temporary db file");
29
30 process::exit(status);
31}
32