database: Add a lot of logging

This commit is contained in:
Elias Projahn 2021-04-25 23:12:19 +02:00
parent 20683ca824
commit f967f6ade9
9 changed files with 30 additions and 4 deletions

View file

@ -7,6 +7,7 @@ extern crate diesel;
extern crate diesel_migrations;
use diesel::prelude::*;
use log::info;
pub mod ensembles;
pub use ensembles::*;
@ -53,9 +54,11 @@ pub struct Database {
impl Database {
/// Create a new database interface and run migrations if necessary.
pub fn new(file_name: &str) -> Result<Database> {
info!("Opening database file '{}'", file_name);
let connection = SqliteConnection::establish(file_name)?;
diesel::sql_query("PRAGMA foreign_keys = ON").execute(&connection)?;
info!("Running migrations if necessary");
embedded_migrations::run(&connection)?;
Ok(Database { connection })