From 6fc667ffc94200b66a14be00f0ce539fcf03b4fc Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sun, 13 Feb 2022 00:18:49 +0530 Subject: [PATCH] feat: run migrations on start up --- src/db.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/db.rs b/src/db.rs index 432db90..42f20eb 100644 --- a/src/db.rs +++ b/src/db.rs @@ -33,7 +33,9 @@ pub mod pg { pool_options, url: settings.database.url, }); - let db = Box::new(connection_options.connect().await.unwrap()); + let db = connection_options.connect().await.unwrap(); + db.migrate().await.unwrap(); + let db = Box::new(db); db } @@ -54,7 +56,9 @@ pub mod sqlite { url: settings.database.url, }); - let db = Box::new(connection_options.connect().await.unwrap()); + let db = connection_options.connect().await.unwrap(); + db.migrate().await.unwrap(); + let db = Box::new(db); db } }