Skip to content

Commit

Permalink
scaffold init
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Oct 10, 2024
1 parent d7ff8dc commit b979eea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions warehouse/src/migrate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use sqlx::PgPool;

pub async fn maybe_init(pool: &PgPool) -> anyhow::Result<()> {
// run through all the migrations in ./sql/migrations.
// note: the path is relative to project root
// and the naming of the files follow a pattern, see migrations/README.md
sqlx::migrate!("tests/mock_migrations").run(pool).await?;
Ok(())
}
9 changes: 9 additions & 0 deletions warehouse/tests/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

use sqlx::{PgPool};

#[sqlx::test]
async fn can_init(pool: PgPool) -> anyhow::Result<()>{
libra_warehouse::migrate::maybe_init(&pool).await?;

Ok(())
}

0 comments on commit b979eea

Please sign in to comment.