14 lines
442 B
Rust
14 lines
442 B
Rust
use sqlx::{PgPool, postgres::PgPoolOptions};
|
|
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))
|
|
.connect(database_url)
|
|
.await
|
|
}
|
|
|
|
pub async fn run_migrations(pool: &PgPool) -> Result<(), sqlx::migrate::MigrateError> {
|
|
sqlx::migrate!("./migrations").run(pool).await
|
|
} |