From df63c25646191c794634515d58038ee6630ba871 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Tue, 22 Aug 2017 09:37:40 +0200 Subject: [PATCH] Run migrations on start, not on every connection --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 272a002..8fd7691 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,11 +46,14 @@ fn core_main() -> Result<(), Box> { .map(|p| p.parse().expect("Guaranteed by validator")) .unwrap_or(8080); + // Connect to the database and run migrations up front: + db::connect_database(&db_file, true); + let server = hyper::server::Http::new() .bind( &SocketAddr::new(bind_host, bind_port), - move || Ok(site::Site::new(state::State::new(db::connect_database(&db_file, true)))) + move || Ok(site::Site::new(state::State::new(db::connect_database(&db_file, false)))) )?; server.run()?;