chore: 🧹 rename RUSTLER_DATABASE to DATABASE_URL in connection handling
This commit is contained in:
parent
ecb8d874c2
commit
e9427b769e
@ -35,21 +35,20 @@ pub mod db {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const RUSTLER_DATABASE: &str = "RUSTLER_DATABASE";
|
const DATABASE_URL: &str = "DATABASE_URL";
|
||||||
|
|
||||||
fn get_default_conn_str() -> String {
|
fn get_default_conn_str() -> String {
|
||||||
let conn_str = s!("sqlite://rustler.db?mode=rwc");
|
let conn_str = s!("sqlite://rustler.db?mode=rwc");
|
||||||
info!(
|
info!(
|
||||||
"No `{}` env var found, using default: {}",
|
"No `{}` env var found, using default: {}",
|
||||||
RUSTLER_DATABASE.italic(),
|
DATABASE_URL.italic(),
|
||||||
conn_str.green()
|
conn_str.green()
|
||||||
);
|
);
|
||||||
conn_str
|
conn_str
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_connection() -> Result<DatabaseConnection> {
|
pub async fn get_connection() -> Result<DatabaseConnection> {
|
||||||
let db_conn_str =
|
let db_conn_str = std::env::var(DATABASE_URL).unwrap_or_else(|_| get_default_conn_str());
|
||||||
std::env::var(RUSTLER_DATABASE).unwrap_or_else(|_| get_default_conn_str());
|
|
||||||
|
|
||||||
let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned());
|
let mut conn_opts = ConnectOptions::new(db_conn_str.to_owned());
|
||||||
conn_opts.sqlx_logging(false);
|
conn_opts.sqlx_logging(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user