graphile / migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
MIT License
751 stars 58 forks source link

DATABASE_URL being overwritten #80

Closed davecardwell closed 4 years ago

davecardwell commented 4 years ago

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?

benjie commented 4 years ago

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.

davecardwell commented 4 years ago

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.

benjie commented 4 years ago

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

davecardwell commented 4 years ago

@benjie Works for me—thanks!