Skip to content

Allow configuration option for dotenv path. #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
henrypenny opened this issue Nov 20, 2017 · 13 comments · Fixed by #613
Closed

Allow configuration option for dotenv path. #517

henrypenny opened this issue Nov 20, 2017 · 13 comments · Fixed by #613
Labels

Comments

@henrypenny
Copy link

henrypenny commented Nov 20, 2017

dotenv only works if your .env file is in the root folder.
It would be nice to have an option to have that file elsewhere. eg:

./node_modules/db-migrate/bin/db-migrate --dotenv ./config/.env ...

@stale
Copy link

stale bot commented Dec 20, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 20, 2017
@cpheimbach
Copy link

It's a bit sad it's gone stale but I suggest this to be looked into as well.

Maybe there is a different approach to why I need that: I work with docker and therefore have my .env file in a subfolder for the server.

@stale stale bot removed the stale label Dec 23, 2017
@wzrdtales
Copy link
Member

I'm open to PRs though, haven't looked into this yet at all, so can't tell if the library we use allows changing the path to the file. But I hardly guess it does.

@cpheimbach
Copy link

Let me have a look. I am quite new to contributing on github but happy to check. The library you are using I guess is dotenv for loading the .env file variables into the process.env object.

The good news is that dotenv allows for a path definition: https://github.com/motdotla/dotenv#options

What I guess I have to figure out is how we can use command line parameters as an input to define this config variable (or to default to root if none is passed in).

Thanks for offering to contribute!

@stale
Copy link

stale bot commented Jan 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 23, 2018
@stale stale bot closed this as completed Jan 30, 2018
@thedaniel
Copy link

It's a shame this was closed as stale, I could use this feature at work right now.

@wzrdtales
Copy link
Member

Well go ahead and open a PR.

@thedaniel
Copy link

I would have already done so if I had the time to do it, just expressing my support for the feature.

In the meantime, and perhaps helpful for others reading this issue, I am just writing a simple scripts/db-migrate-test.js script that starts with this:

require('dotenv').config({path: path.join(__dirname, '../.env.test')});

And then (assuming everything works as expected) running migrations following this example repo: https://github.com/db-migrate/api-examples/blob/master/index.js

@wzrdtales wzrdtales added feature and removed stale labels Jun 6, 2018
@wzrdtales
Copy link
Member

A "could we reopen this, would be quite useful for me" would have been way more appropriate, than "iit's a shame".

@wzrdtales wzrdtales reopened this Jun 6, 2018
@vkowalke
Copy link

vkowalke commented Jul 9, 2018

In a monorepo environment with lerna the migration script will not work until this problem is fixed!

@kiliw
Copy link

kiliw commented Nov 11, 2020

Please someone document this.

@wzrdtales
Copy link
Member

@kiliw Feel free, don't talk, do -> https://github.com/db-migrate/english-docs

@kiliw
Copy link

kiliw commented Nov 11, 2020

@wzrdtales Thanks for your response. I tried the command from #613 (comment) but the custom path is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants