goose icon indicating copy to clipboard operation
goose copied to clipboard

feature request: Add environment variable support for migrations directory.

Open timuckun opened this issue 2 years ago • 8 comments

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.

timuckun avatar Apr 11 '22 04:04 timuckun

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.

mfridman avatar Apr 14 '22 01:04 mfridman

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.

timuckun avatar Apr 15 '22 04:04 timuckun

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

mfridman avatar Apr 23 '22 02:04 mfridman

https://stackoverflow.com/a/30969768/385548 ;)

VojtechVitek avatar Apr 28 '22 09:04 VojtechVitek

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"

BatuhanW avatar Sep 16 '22 10:09 BatuhanW

Please and dotenv processing.

hiendaovinh avatar Aug 31 '23 08:08 hiendaovinh

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)

mfridman avatar Dec 18 '23 01:12 mfridman

.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"

mansguiche avatar Jul 14 '24 10:07 mansguiche