0

I deployed my app using Heroku, but while deploying Heroku created a new PostgreSQL database. Now I need to change that to my already existing PostgreSQL database(I am using Django framework in VsCode), which I used while running in the localhost. Does anyone have an idea, please help me with this?.

1 Answer 1

0

I would create a database dump and import it into your Heroku Postgres. Use pg_dumpto create a dump and then upload it to heroku. A detailed description can be found on the heroku dev center

Additionally, there is a quite good Stackoverflow entry on this topic here

According to this follow these steps and you should be fine.

Create a dump from the source PostgreSQL database

   $ PGPASSWORD=YOUR_PG_PASSWORD pg_dump -Fc --no-acl --no-owner -h localhost -U YOUR_PG_USER YOUR_DB_NAME > YOUR_DB_NAME.dump

Get the Heroku Postgres credentials for your heroku app

$ heroku pg:credentials:url -a YOUR_APP_NAME

Attempt to import PostgreSQL dump to Heroku using the credentials above

$ pg_restore --verbose --clean --no-acl --no-owner -h HOSTNAME -U USER -d DATABASE -p PORT PATH/TO/YOUR_DB_NAME.dump --password

Enter the password received from the Heroku Postgres credentials It should then import the dump successfully

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

2 Comments

How will you generate a signed URL? Whether will it be a canned policy or custom policy
I will update my answer as I have found a similar question

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.