soaricarus_api CI / Check (push) Successful in 3m21s
soaricarus_api CI / Test Suite (push) Successful in 4m25s
soaricarus_api CI / Rustfmt (push) Successful in 3m8s
soaricarus_api CI / Clippy (push) Successful in 3m56s
soaricarus_api CI / build (push) Successful in 3m3s
Reviewed-on: #253
23 lines
572 B
Rust
23 lines
572 B
Rust
use sqlx::postgres::PgPoolOptions;
|
|
|
|
pub mod connection_settings {
|
|
pub const MAXCONN: u32 = 10;
|
|
}
|
|
|
|
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
|
let database_url = sienvy::environment::get_db_url().value;
|
|
println!("Database url: {database_url}");
|
|
|
|
PgPoolOptions::new()
|
|
.max_connections(connection_settings::MAXCONN)
|
|
.connect(&database_url)
|
|
.await
|
|
}
|
|
|
|
pub async fn migrations(pool: &sqlx::PgPool) {
|
|
sqlx::migrate!("./migrations")
|
|
.run(pool)
|
|
.await
|
|
.expect("Failed to run migrations");
|
|
}
|