aboutsummaryrefslogtreecommitdiff
path: root/src/db/mod.rs
blob: 20e7f817aa96d90a0342f66d899c159b330ba683 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub mod categories;
pub mod event_color;
pub mod events;

use anyhow::Result;
use rusqlite::Connection;
use rusqlite_migration::{Migrations, M};

pub fn init(db_path: &str) -> Result<Connection> {
    let mut conn = Connection::open(db_path)?;
    let migrations = Migrations::new(vec![
        M::up(include_str!("migrations/1-init.sql")),
        M::up(include_str!("migrations/2-categories.sql")),
        M::up(include_str!("migrations/3-event-color.sql")),
    ]);
    migrations.to_latest(&mut conn)?;
    Ok(conn)
}