graphile/migrate

DATABASE_URL being overwritten

davecardwell opened this issue · 4 comments

In my .gmrc I have an afterCurrent command specified as { "_": "command", "command": "yarn seed" }, which runs graphile-migrate run on some .sql files.

With the change in 0.3.1 this no longer works because graphile-migrate is setting GM_DBURLto the correct value, and then changing DATABASE_URL to postgres://PLEASE:USE@GM_DBURL/INSTEAD. This means that graphile-migrate run errors with:

Error: getaddrinfo ENOTFOUND gm_dburl
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'gm_dburl'

I’m not sure what the best solution is here. Should the graphile-migrate CLI be using GM_DBURL if it set? If GM_DBURL is set and DATABASE_URL === postgres://PLEASE:USE@GM_DBURL/INSTEAD? Should I be doing something different?

Interesting question. Having Graphile Migrate detect GM_DBURL seems sensible... Should this only affect the run command, I wonder?

As a workaround, you can do:

DATABASE_URL="$GM_DBURL" graphile-migrate run

Incidentally, this is exactly the kind of issue that this was designed to catch.

Thanks, @benjie. DATABASE_URL="$GM_DBURL" is ultimately what I ended up doing.

Looking through the available commands as they are now it seems graphile-migrate run is the only one it is relevant to.

@davecardwell What do you think about #86 as a solution?

@benjie Works for me—thanks!