Skip to content

Commit 2d05632

Browse files
committed
Use dotenv for all environment variables not just DATABASE_URL
We were ignoring the `MIGRATION_DIRECTORY` variable if it came from `.env`
1 parent 2893bfa commit 2d05632

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

diesel_cli/src/database.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use diesel::{migrations, Connection, select, LoadDsl};
99

1010
use database_error::DatabaseResult;
1111

12-
use dotenv::dotenv;
13-
1412
use std::error::Error;
1513
use std::{env, fs};
1614

@@ -231,8 +229,6 @@ pub fn schema_table_exists(database_url: &String) -> DatabaseResult<bool> {
231229
}
232230

233231
pub fn database_url(matches: &ArgMatches) -> String {
234-
dotenv().ok();
235-
236232
matches.value_of("DATABASE_URL")
237233
.map(|s| s.into())
238234
.or(env::var("DATABASE_URL").ok())

diesel_cli/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use std::{env, fs};
2424
use self::database_error::{DatabaseError, DatabaseResult};
2525

2626
fn main() {
27+
use self::dotenv::dotenv;
28+
dotenv().ok();
29+
2730
let database_arg = Arg::with_name("DATABASE_URL")
2831
.long("database-url")
2932
.help("Specifies the database URL to connect to. Falls back to \

0 commit comments

Comments
 (0)