use sqlx::PgPool;
use sqlx::postgres::PgPoolOptions;
pub async fn create_pool(cfg: &crate::Config) -> sqlx::Result<PgPool> {
tracing::debug!(cfg.database_url, "connecting to db");
let opts = PgPoolOptions::new().max_connections(cfg.db_max_conns);
let pool = opts.connect(&cfg.database_url).await?;
sqlx::migrate!().run(&pool).await?;
Ok(pool)
}
#[derive(Clone, Debug, PartialEq, Eq, sqlx::FromRow, serde::Serialize, serde::Deserialize)]
pub struct Key {
pub id: String,
pub userid: String,
pub pri: String,
}
#[derive(Clone, Debug, PartialEq, Eq, sqlx::FromRow, serde::Serialize, serde::Deserialize)]
pub struct Repo {
pub id: i32,
pub name: String,
pub key_id: Option<String>,
}