init: scaffold from k-template with postgres + worker
This commit is contained in:
14
crates/adapters/postgres/src/db.rs
Normal file
14
crates/adapters/postgres/src/db.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
pub type PgPool = sqlx::PgPool;
|
||||
|
||||
pub async fn connect(url: &str) -> anyhow::Result<PgPool> {
|
||||
let pool = sqlx::postgres::PgPoolOptions::new()
|
||||
.max_connections(10)
|
||||
.connect(url)
|
||||
.await?;
|
||||
Ok(pool)
|
||||
}
|
||||
|
||||
pub async fn run_migrations(pool: &PgPool) -> anyhow::Result<()> {
|
||||
sqlx::migrate!("./migrations").run(pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user