diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-02-11 18:42:30 -0500 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-02-11 18:42:30 -0500 |
commit | 1be4dce20256f22d0be648fad016e819a050e95d (patch) | |
tree | d2795239360168969ceae3d7d909035277e24841 /src/main.rs | |
parent | 32d3fa0eaea214c0c291ac6387cd4289b9cec69a (diff) |
Add embedded diesel db migrations
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index ec0e660..13e4cd2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ extern crate fern; #[macro_use] extern crate log; extern crate clap; +#[macro_use] +extern crate diesel_migrations; use chrono::Utc; use clap::App; @@ -15,6 +17,8 @@ use pjournal::importer; use pjournal::models; use serde_json::to_value; +embed_migrations!(); + fn setup_logger() -> Result<(), fern::InitError> { use fern::colors::{Color, ColoredLevelConfig}; let colors = ColoredLevelConfig::new(); @@ -140,6 +144,8 @@ fn main() { let db_url = matches.value_of("database_url").unwrap(); let conn = PgConnection::establish(db_url).unwrap(); + embedded_migrations::run(&conn).unwrap(); + if let Some(matches) = matches.subcommand_matches("init") { let config = models::Config { strava_client_id: matches.value_of("strava_client_id").unwrap().to_string(), |