migra icon indicating copy to clipboard operation
migra copied to clipboard

Support .pgpass files for migra

Open waterkip opened this issue 3 years ago • 1 comments

This eases the whole connection URI setup for developers who make use of the .pgpass file.

Signed-off-by: Wesley Schwengle [email protected]

waterkip avatar May 28 '22 17:05 waterkip

Hi, I didn't wrote a test for it because I'm too dumb I guess to get a working developer environment. So I did tests with my own setup which work.

Test prerequisites:

  • A .pgpass file:
localhost:5432:*:yourdbuser:yourdbpassword
  • Have two databases, eg foo and bar

How to test:

  • invoke migra as usual, but without your username and password, in this case I assume your local user equals the postgres username:
   migra \
     postgresql://localhost/foo \
     postgresql://localhost/bar \
     --unsafe --ignore-extension-versions
  • This should yield a connection

  • invoke migra as usual, but a with username but without a password:

   migra \
     postgresql://yourdbuser@localhost/foo \
     postgresql://yourdbuser@localhost/bar \
     --unsafe --ignore-extension-versions
  • This should yield a connection

  • invoke migra as usual, but a with username but without a password and make sure you have a DB named the same as your user::

   migra \
     postgresql://yourdbuser@localhost/ \
     postgresql://yourdbuser@localhost/bar \
     --unsafe --ignore-extension-versions
  • This should yield a connection

When you remove the .pgpass file you should not get a connection and migra fails as it did in the past.

waterkip avatar May 28 '22 17:05 waterkip