thoughtbot / parity

Shell commands for development, staging, and production parity for Heroku apps
https://thoughtbot.com
MIT License
889 stars 57 forks source link

Restore to non-localhost database #204

Open pangolingo opened 1 year ago

pangolingo commented 1 year ago

I would like to use parity to restore Heroku to a dev database. But that catch is that the dev database is not available at localhost. It's running in a Docker container (I'm also running the parity command in another Docker container), and has a hostname, username and password. This is the connection URL: postgresql://postgres:password@db:5432/hub_development?timeout=5000

As far as I can tell, Parity ignores all the DB config expect for the DB name, and tries to connect on localhost with no username/password.


Help us track down and resolve parity problems faster with this template.

What command did you execute?

development restore production

What did you expect to happen?

I expected the Prod database to be downloaded and restored to my local database (which is running in a Docker container using Docker Compose)

What actually happened?

I got an error:

dropdb: error: could not connect to database template1: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
pg_restore: connecting to database for restore
pg_restore: error: connection to database "hub_development" failed: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
psql: error: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Some information about your installation

What's your operating system? the mcr.microsoft.com/devcontainers/ruby:3.2 Docker container

What's the output of which development, which staging, which production?

vscode ➜ /workspaces/hub (feat/dockerize) $ which development
/usr/local/rvm/gems/default/bin/development
vscode ➜ /workspaces/hub (feat/dockerize) $ which staging
/usr/local/rvm/gems/default/bin/staging
vscode ➜ /workspaces/hub (feat/dockerize) $ which production
/usr/local/rvm/gems/default/bin/production

If installed via Rubygems, what's the gem version? 3.5.0

pangolingo commented 1 year ago

I believe these two other PRs were attempting to address this:

https://github.com/thoughtbot/parity/pull/106

https://github.com/thoughtbot/parity/pull/173