Thursday, January 24, 2013

Rails pg gem '0.14.1' on Mac fails and solution

pg.c: In function ‘Init_pg_ext’:
pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:384: error: (Each undeclared identifier is reported only once
pg.c:384: error: for each function it appears in.)
pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1

Solution:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.2/bin/pg_config

EDIT :
If you dont know where your pg_config is. Assume you are on Linux/Mac system, using the command 'find' should help

find / -name pg_config
 
 


How to copy postgresql data from heroku production

Steps to get the copy of heroku deployed application database to localhost .

1 step: Create a backup on heroku production
       
           heroku pgbackups:capture --expire

2 step:  Get the latest back up to local by curl method

           curl -o backup.dump `heroku pgbackups:url`
3 step: Restore to localhost database using the followng comand
  
   pg_restore --verbose --clean --no-acl --no-owner -h localhost -d your_database_name  backup.dump