gmrc `connectionString` should be ignored if `DATABASE_URL` exists in the env
samlevin opened this issue · 1 comments
Hey Benjie. We've nearly completed our adoption of graphile-migrate and as a team, we're loving it. A lot of great philosophies at play. Awesome work all around.
Our development team has a 'zero config' dev environment philosophy where a lot of settings are hard-coded to repositories (with insecure defaults). We're trying to replicate this for graphile-migrate but the migrate
command appears to be preferring connectionString
- even though DATABASE_URL
exists.
Thoughts? ENV var precedence is fairly typical in the config world. Am I right in assuming that migrate would/should follow suit?
No; explicit always wins over implicit. If you provide a connection string explicitly via the Graphile Migrate config file then that will override the implicit and generic environmental variable DATABASE_URL
that may have come from anywhere and could relate to some other service such as PostGraphile or Graphile Worker or even a completely different project.
Perhaps there's an alternative way we can solve this; for example a .js
config file where you can set connectionString: process.env.DATABASE_URL || "fallback"
This'd be the place to apply that change:
migrate/src/commands/_common.ts
Lines 7 to 23 in 08e0b27
I think read .gmrc
if present, otherwise try .gmrc.js
.