From 180a4a7771c25c6b269ae2d272faa38243d1d0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bananent=C3=BCrkis?= <12024604-beckersam@users.noreply.gitlab.com> Date: Sun, 31 Dec 2023 19:01:38 +0100 Subject: [PATCH] :neocat_woozy: It works nyow --- src/storage/mod.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) 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