3

I need to assess the database schema of the Postgres instance running on Heroku. Without luck, I have tried the following methods:

heroku run -a my_app_name 'pg_dump -s DATABASE_URL' > output.sql

where DATABASE_URL would be the whole string out of

heroku config:get DATABASE_URL -a my_app_name

This is the closest I could get, as the command runs but the output is left empty. For this I added the flag -s for pg_dump to only get the schema and no data.

I have also tried following this answer but couldn't use it to get the schema.

3
  • 1
    Your first heroku run -a ... one should work fine, worked for me just now. Are you sure you're using the right DATABASE_URL? Commented Feb 19, 2019 at 4:38
  • 1
    Thanks @muistooshort, you are right, I eventually got the output file, successful as it ends with -- PostgreSQL database dump complete . However, I am not sure how long it took, the command execution never ends and I have to close the terminal window once done because not responding. Anyway good. Commented Feb 21, 2019 at 4:46
  • 1
    Your answer was the only thing that worked for me after hours of trying... In my case I copied DATABASE_URL from the heroku -> my app -> resources -> view database credentials then copied URI if that helps anybody else. Commented Oct 14, 2021 at 16:23

1 Answer 1

0

If you need permission to access the app, you can run it.

heroku pg:pull DATABASE_URL local_db_name --exclude-table-data="*.*" --app heroku_app_name

It will pull all the tables' structures but no data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.