diff --git a/src/storage/mod.rs b/src/storage/mod.rs index a19f53f..5c18d64 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -15,21 +15,12 @@ use std::error::Error; pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations"); -pub fn establish_connection(db_url: &str) -> PgConnection { +pub fn establish_connection(db_url: &str) -> Result { //SqliteConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e)) let mut conn = PgConnection::establish(db_url) .unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e)); // TODO: Add migrations here - conn + let c: MigrationHarness = &mut conn; + c.run_pending_migrations(MIGRATIONS)?; + Ok(conn) } - -fn run_migrations_sqlite(connection: &mut impl MigrationHarness) -> Result<(), Box> { - - // This will run the necessary migrations. - // - // See the documentation for `MigrationHarness` for - // all available methods. - connection.run_pending_migrations(MIGRATIONS)?; - - Ok(()) -} \ No newline at end of file