Search code examples
herokuheroku-toolbeltheroku-postgres

Setup heroku environment on different machine


I have two laptops, one work laptop and another personal laptop. I have setup the Heroku environment on the work laptop. In git repo I have added github as origin and heroku as separate remote. Whenever I need to deploy anything I just use heroku remote to push my changes. Now I have already cloned my code from github and also installed heroku-toolbelt on the second laptop. Now I want to push my code and access Postgres database from second laptop. But not sure how to do it. I am able to see the app config parameter by this command.

heroku config --app <MY-APP-NAME>

But when I try to access database I am not able to do so. The pg sub-command doesn't provide --app option to specify the app name. I tried to look into heroku fork but this command will basically create another app from an existing app. I don't want to do this. I also looked into herku git:clone but this command will basically clone the repo. I have already cloned my repo from githu. I am not sure how to have the same heroku enviornment as I have on my work laptop.

EDIT1

I executed the following command to add heroku remote in git config.

heroku git:remote -a <MY-APP-NAME>

So I don't need to specify the --app option to access the config. It automatically picks the right config. But I when I try to access the Postgres database it gives me following error.

>heroku pg:psql
---> Connecting to DATABASE_URL
sh: psql: command not found

This exact same command works on another laptop.

EDIT2

I figured out the problem. Actually heroku is trying to run psql on my local box but psql was not installed on my machine and hence it couldn't successfully connect to remote database. So I executed the following command to install psql and it worked like charm.

brew install postgres

Solution

  • First add the git remote by executing the following line.

    heroku git:remote -a <MY-APP-NAME>
    

    Then make sure your system has the postgres client installed. If it is not installed then installed it using the following command.

    brew install postgres
    

    The above command is only valid for Mac which has brew installed. You can search internet to find the specific command for your own platform.