11 lines
318 B
Rust
11 lines
318 B
Rust
use anyhow::Result;
|
|
use sqlx::{postgres::PgPoolOptions, PgPool};
|
|
|
|
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
|
|
let pool = PgPoolOptions::new()
|
|
.max_connections(10)
|
|
.connect(database_url)
|
|
.await?;
|
|
sqlx::migrate!("src/db/migrations").run(&pool).await?;
|
|
Ok(pool)
|
|
}
|