config: simplify runtime environment model
This commit is contained in:
@@ -10,7 +10,7 @@ use serde::{Serialize, de::DeserializeOwned};
|
||||
use serde_json::Value;
|
||||
use sqlx::{
|
||||
PgPool, Postgres, Row, Transaction,
|
||||
postgres::{PgPoolOptions, PgRow},
|
||||
postgres::{PgConnectOptions, PgPoolOptions, PgRow},
|
||||
types::Json,
|
||||
};
|
||||
|
||||
@@ -46,6 +46,14 @@ impl PostgresRegistry {
|
||||
Self::connect_in_schema(database_url, None).await
|
||||
}
|
||||
|
||||
pub async fn connect_with_options(
|
||||
connect_options: PgConnectOptions,
|
||||
) -> Result<Self, RegistryError> {
|
||||
let pool = PgPoolOptions::new().connect_with(connect_options).await?;
|
||||
migrations::apply_postgres(&pool).await?;
|
||||
Ok(Self { pool })
|
||||
}
|
||||
|
||||
pub fn pool(&self) -> &PgPool {
|
||||
&self.pool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user