-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a --test-db global parameter to use TEST_DATABAE_URL env instead #4201
base: master
Are you sure you want to change the base?
Conversation
…DATABASE_URL env instead of DATABASE_URL env
688a88e
to
3be9224
Compare
Thanks for opening this PR. |
@weiznich yes I do have my DATABASE_URL setup in a .env file, however that means that will load it for one environment. That has been the issue is that I sometimes need to switch between multiple environments (the common ones are between dev and testing). Working with other frameworks (such as the infamous ruby on rails) their CLI tools support an "environment" override param to switch between development, test, and production (or any other you create) which allows easy switching between dev & testing to work on the database. What I have been doing thus far is I have a local script in my project named diesel-test.sh with this contents. #!/bin/sh
. .env
export DATABASE_URL=$TEST_DATABASE_URL
diesel "$@" However this did not have tab-completion thus making it harder to use on the command line (I live on the CLI). Digging in some more I found an alternative that accomplishes the same as what this PR provides by doing this.
I may fiddle more with that diesel-test script as another alternative approach would be to have it load the env from .env.test (e.g. load .env then load .env.test) and having that built-into the diesel cli might be night.. e.g. a |
Thanks for providing these details. I think I now understand at least the problem that you are trying to solve. I'm still not sold on the implemented approach.
That sounds like a much better solution. I would be open to accept a PR that implements such a flag, so that the prefix is used while loading |
The use case here is I have my local development setup where I have two databases setup, development and testing.
my .env has
Currently I have a wrapper diesel-test.sh script that load the .env and switches DATABASE_URL with TEST_DATABASE_URL's contents. However this interrupts the code-completion in my shell when running changes against my test DB.
This PR adds a --test-db (-t) global parameter that will do that switch for me in the cli so I can easily switch between the two environments on the command line and still have code-completion easily.
diesel -t migration run
Outstanding issues/questions