Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Pull From Heroku Using Pg:Pull

I have successfully deployed my Rails app to Heroku. It is working fine but I am unable to pull the data into my local database

Local postgres database name is development

Here is my database.yaml file

development:
  adapter: postgresql
  database: development
  username: ambanerj
  password: *********
  host: localhost
  encoding: UTF8
   pool: 5
  timeout: 5000

 production:
   adapter: postgresql
   database: development
   host: localhost
   username: ambanerj
   password: *********
   pool: 5
   timeout: 5000

 test:
   adapter: postgresql
   database: app_test
   host: localhost
   username: ambanerj
   password: *********
   pool: 5
   timeout: 5000

When I run the command

heroku pg:pull

I get this

 Usage: heroku pg:pull <REMOTE_SOURCE_DATABASE> <LOCAL_TARGET_DATABASE>

 pull from REMOTE_SOURCE_DATABASE to LOCAL_TARGET_DATABASE
 LOCAL_TARGET_DATABASE must not already exist.

Can anyone tell me how do I go about this one and pull data from my Heroku DB into local development database? I have tried pg:pull with the options without success

Here is what I see in my Heroku dashboard.

Host    ec2-54-225-101-18.compute-1.amazonaws.com
Database    dd8hgh6m3vl6t7
User    mckuffxoufgewi
Port    5432
Password    
Psql    heroku pg:psql --app immense-dawn-3007 black
URL 

Please tell me the format of using pg:pull command with an example if possible.

P.S: I tried using Taps gem without success

like image 362
Amit Banerjee Avatar asked Aug 14 '14 16:08

Amit Banerjee


1 Answers

To pull pg remote database to your local, you need to follow following command from your app root terminal:

 heroku pg:pull HEROKU_POSTGRESQL_[SOME COLOR NAME] mylocaldb --app shushi

This command will create a new local database named “mylocaldb” and then pull data from database at DATABASE_URL from the app “sushi”. In order to prevent accidental data overwrites and loss, the local database must not exist. Read more

When you do heroku config:get -a secure-gorge-4090, you should see an entry for HEROKU_POSTGRESQL_[SOME COLOR NAME]. Make sure you're using whatever that token is instead of DATABASE in your commands. courtesy

like image 58
RAJ Avatar answered Oct 07 '22 15:10

RAJ