All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 37s
Rust Build / Test Suite (push) Successful in 47s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 39s
Rust Build / build (push) Successful in 1m2s
Rust Build / Check (pull_request) Successful in 38s
Rust Build / Test Suite (pull_request) Successful in 50s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 40s
Rust Build / build (pull_request) Successful in 1m6s
Reviewed-on: #44 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
36 lines
915 B
Rust
36 lines
915 B
Rust
pub mod callers;
|
|
pub mod config;
|
|
pub mod hashing;
|
|
pub mod repo;
|
|
pub mod token_stuff;
|
|
|
|
mod connection_settings {
|
|
pub const MAXCONN: u32 = 5;
|
|
}
|
|
|
|
pub mod db {
|
|
|
|
use sqlx::postgres::PgPoolOptions;
|
|
|
|
use crate::connection_settings;
|
|
|
|
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
|
let database_url = icarus_envy::environment::get_db_url().await;
|
|
println!("Database url: {database_url}");
|
|
|
|
PgPoolOptions::new()
|
|
.max_connections(connection_settings::MAXCONN)
|
|
.connect(&database_url)
|
|
.await
|
|
}
|
|
|
|
pub async fn migrations(pool: &sqlx::PgPool) {
|
|
// Run migrations using the sqlx::migrate! macro
|
|
// Assumes your migrations are in a ./migrations folder relative to Cargo.toml
|
|
sqlx::migrate!("./migrations")
|
|
.run(pool)
|
|
.await
|
|
.expect("Failed to run migrations");
|
|
}
|
|
}
|