Skip to content
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

setting DATABASE_URL doesn't ignore defaultEnv from .db-migraterc #564

Open
1 of 3 tasks
gudatcomputers opened this issue Apr 25, 2018 · 4 comments · May be fixed by #584
Open
1 of 3 tasks

setting DATABASE_URL doesn't ignore defaultEnv from .db-migraterc #564

gudatcomputers opened this issue Apr 25, 2018 · 4 comments · May be fixed by #584
Labels

Comments

@gudatcomputers
Copy link

gudatcomputers commented Apr 25, 2018

I'm submitting a...

  • Bug report
  • Feature request
  • Question

Current behavior

running db-migrate with DATABASE_URL defined does not ignore defaultEnv from .db-migraterc

Expected behavior

running db-migrate with DATABASE_URL respects that value and doesn't try to read defaultEnv from .db-migraterc

Minimal reproduction of the problem with instructions

  1. export DATABASE_URL=mysql://<some-valid-connection-string>
  2. create a .db-migraterc with a defaultEnv configured. I chose local instead of dev for my example.
  3. Run db-migrate.
  4. You will see something like "environment 'local' is not defined"

What is the motivation / use case for changing the behavior?

When setting database URL, the intent is that it is defining everything about your environment. To respect the defaultEnv setting from .db-migraterc seems to contradict that

Environment


db-migrate version: 0.11.1
plugins with versions: unknown, don't think I'm using plugins?
db-migrate driver with versions: 
mysql 1.1.10

Additional information:
- Node version: 8.9.4
- Platform:  MacOS 10.13

Others:


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@levino
Copy link

levino commented May 3, 2018

Actually I think the 'DATABASE_URL' is totally ignored. I wanted to use it to override my database.json but cannot get it to work.

@wzrdtales
Copy link
Member

I will check that back thanks for reporting. Environment variables should be always favoured before anything else.

@wzrdtales wzrdtales added the bug label May 8, 2018
@jirikrepl
Copy link

I run into similar problem with mongodb url, escaping connection string by double quotes worked for me. export DATABASE_URL="..."

@bill-kitsune bill-kitsune linked a pull request Sep 26, 2018 that will close this issue
@bill-kitsune
Copy link

I have a PR out for this, but there is also a work-around.

@levino my case sounded a lot like yours.

In your database.json you do the following:

{ "heroku": { "ENV": "DATABASE_URL" } }

Then run the migrate command with --env heroku it should work.

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.

5 participants