Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

Error while using pg:push to a Heroku PostgreSQL database

I'm trying to push a local PostgreSQL database to one I've created on a Heroku app. To set up the Heroku database, I ran heroku addons:create heroku-postgresql:hobby-dev -a jasons-react-jobly-app, where jasons-react-jobly-app is the name of my Heroku app.

Then I ran heroku pg:push jobly DATABASE_URL -a jasons-react-jobly-app, where jobly is the name of my local database.

This throws the below error:

heroku-cli: Pushing jobly ---> postgresql-animate-30221
                case
------------------------------------
 0.9992547478473790.999254747847379
(1 row)

 !    Cannot read property 'includes' of undefined

The error looks like an error that JavaScript throws when it tries to read properties of an undefined object or something, but I'm not sure where that would be happening in this database push. The app runs completely fine on my local machine with no errors. There is no case column in any of my database tables, so I'm not sure where that number is coming from either.

Also, if I check my Heroku config variables with heroku config, I see:

DATABASE_URL: postgres://iqawqkjfiybndd:c3e921131c239ccd6c880ad4b601deeaa4558339a90ebedc562a5575c9099f42@ec2-54-156-85-145.compute-1.amazonaws.com:5432/dul2u6r13aq5i

So I know the database exists.

Any help with solving this error?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to fetch the name of the DB that you see attached to the heroku app on heroku dashboard.

At this url https://dashboard.heroku.com/apps/{put-your-app-name-here}/resources To get all app names in heroku cli do heroku apps and you will know which app's DB name you want from its dashboard.

Once you have the name of the DB (it will look like this "postgresql-pointy-81624")

use that name in the command to push local db to that db on heroku .

Here are steps to make sure everything works correctly 1- Check the connectivity to the heroku db first by doing

heroku pg:psql postgresql-[somedb name as found above] --app {your-app-name}

2- If it says to reset the DB and you can afford to reset then reset it using

heroku pg:reset -a {your-app-name}

3- Lastly do the migration of DB using this command

heroku pg:push jobly postgresql-[db name found above] -a {your-app-name}

if everything works as expected you will see this message

heroku-cli: Pushing complete.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...