use include_dir::{include_dir, Dir};
use rusqlite::Connection;
use rusqlite_migration::Migrations;
static MIGRATION_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/migrations/core");
static OPERATIONS_MIGRATION_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/migrations/operations");
pub fn run_migrations(conn: &mut Connection) {
let migrations = Migrations::from_directory(&MIGRATION_DIR).unwrap();
conn.pragma_update_and_check(None, "journal_mode", "WAL", |_| Ok(()))
.unwrap();
conn.pragma_update(None, "foreign_keys", "ON").unwrap();
conn.execute("PRAGMA cache_size=50000;", []).unwrap();
conn.execute("PRAGMA synchronous = NORMAL;", []).unwrap();
let r = migrations.to_latest(conn);
r.unwrap()
}
pub fn run_operation_migrations(conn: &mut Connection) {
let migrations = Migrations::from_directory(&OPERATIONS_MIGRATION_DIR).unwrap();
conn.pragma_update_and_check(None, "journal_mode", "WAL", |_| Ok(()))
.unwrap();
conn.pragma_update(None, "foreign_keys", "ON").unwrap();
conn.execute("PRAGMA cache_size=50000;", []).unwrap();
let r = migrations.to_latest(conn);
r.unwrap()
}