goose
goose copied to clipboard
feature request: Add environment variable support for migrations directory.
Currently there are the options for
GOOSE_DRIVER=DRIVER GOOSE_DBSTRING=DBSTRING
It should also support a env var for migrations directory.
It should also detect and process a .env file if one exists.
Hmm, I can't think of a good reason why there is no env option for the migrations directory.
Not sure about processing .env though. I think most users will have something like https://github.com/direnv/direnv, https://www.npmjs.com/package/dotenv (or equivalent) to load/unload env variable.
So as long as goose
understands just the env variables it should be sufficient.
Reading the .env file would be convenient when using it as a CLI.
I know you can use other software on top but it seems like an easy feature to add and would be very convenient.
Opened a PR to add this env variable GOOSE_MIGRATION_DIR
.
I'm not entirely sold on adding .env support into goose directly. I think .env, .envrc, etc. are a solved problem outside CLI's, but I could be wrong.
I'm inclined to leave it as an env variable for now, but we can always revisit this if more folks ask for it and use something like: https://github.com/joho/godotenv
https://stackoverflow.com/a/30969768/385548 ;)
If not .env
, having something like .gooseconfig
file that we can configure would be really nice.
$ cat .gooseconfig
GOOSE_DRIVER=postgres
GOOSE_DBSTRING="host=localhost user=docker password=docker dbname=docker sslmode=disable"
Please and dotenv processing.
Re-opening this issue so we can track its popularity, and differentiate it from https://github.com/pressly/goose/issues/347 (which is mainly about variable replacement, and less about reading .env files)
.env
support would be useful for me
Even if it was an optional flag that was disabled by default, e.g. goose up -env=".env"