mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-27 04:07:25 +01:00
database: Add a lot of logging
This commit is contained in:
parent
20683ca824
commit
f967f6ade9
9 changed files with 30 additions and 4 deletions
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue