Files
boc/aamos-ledger-rust/crates/aamos-db/src/lib.rs
T

17 lines
577 B
Rust
Raw Normal View History

use sqlx::{postgres::PgPoolOptions, PgPool};
use std::time::Duration;
pub async fn create_pool(database_url: &str) -> Result<PgPool, sqlx::Error> {
PgPoolOptions::new()
.max_connections(10)
.acquire_timeout(Duration::from_secs(30))
.idle_timeout(Duration::from_secs(300))
.connect(database_url)
.await
}
pub async fn run_migrations(pool: &PgPool) -> Result<(), sqlx::migrate::MigrateError> {
// Migrations are run from the workspace root where migrations/ folder exists
sqlx::migrate!("../../migrations").run(pool).await
}