Search code examples
herokugithubtravis-ciheroku-postgresheroku-api

Can I import .dump file to heroku through travis


I am having a QA instance which contains a very limited data(approx 30-35 MB) it contains images etc, thumbnails hence cannot put them into seed. I have a private repo at github(synced with heroku) which contains a .dump file say abc.dump file and I want to run my test cases from travis, in the before script I will be restoring this dump.

I would like to know how to import this dump to heroku although this is available at heroku bash as well. I looked into the documentation here they say make it asseccible through http somewhere. I am trying using the pg_restore commands using the database username, passwords available at the application database overview available through UI, but not working. Can someone suggest me a good way out to simply restore by not making my database public ? Also. how often the database user/password is changed at heroku ?


Solution

  • As travis would be having access to abc.dump beforehand it can perform basic pg_restore function of postgresql.

    PGPASSWORD=<PASSWORD> pg_restore --verbose --clean --no-acl --no-owner -h <PG_HOSTNAME> -U <PG_USER> -d <PG_DATABASE_NAME> -p <PG_PORT_NO> <DUMP_FILE>.dump

    The above details for the heroku database hostname, user, pass, port etc. can be fount easily using :-

    heroku pg:credentials DATABASE --app application_name