diff --git a/src/db.rs b/src/db.rs index 5eb83ce..593e091 100644 --- a/src/db.rs +++ b/src/db.rs @@ -48,15 +48,21 @@ pub async fn get_pool() -> SqlitePool { .await .expect("can't connect to database"); - let mut m = Migrator::new(std::path::Path::new("./migrations")) - .await - .expect("Should be able to read the migration directory."); + { + let mut m = Migrator::new(std::path::Path::new("./migrations")) + .await + .expect("Should be able to read the migration directory."); - let m = m.set_locking(true); + let m = m.set_locking(true); - m.run(&pool) - .await - .expect("Should be able to run the migration."); + m.run(&pool) + .await + .expect("Should be able to run the migration."); + } + + // hack to ensure that migration has actually run; surely there is a better + // way!! + tokio::time::sleep(Duration::from_secs(1)).await; tracing::info!("Ran migrations"); @@ -70,6 +76,10 @@ pub async fn session_layer(pool: SqlitePool, secret: &[u8]) -> SessionLayer