Open MartinRamm opened 3 years ago
I think this should be achievable by using a "Keyword/Value Connection String" (see https://www.postgresql.org/docs/10/libpq-connect.html)
This would look something like:
npx '@databases/pg-schema-cli' \
--database "host='/var/run/postgresql/' user='$POSTGRES_USER' password='$POSTGRES_PASSWORD' dbname='$POSTGRES_DB'" \
--directory "$TS_FOLDER";
It's also possible to provide most of these parameters via environment variables (PGHOST
, PGUSER
etc.) but currently the pg-schema-cli util does require a connection string of some sort.
I tried using the package
pg-schema-cli
with a db connection via unix socket. For this, I configured aconfig.json
file (implementing this interface) and the--config
option with a path to saidconfig.json
file, but the command outputs that a connection string is required.As far as I can tell, connection strings don't support unix socket paths yet - leaving me no real options here.
My current workaround is to temporarily bind the unix socket to a TCP port via
socat
using this code:However, I think a case could be made to allow this behavior without the workaround. I could imagine the easiest fix that works for all packages could be to extend the schema of the connection string to allow unix sockets as hosts. If the maintenance team agrees with me, I would be willing to provide an implementation (scoped to postgres).