1

I need to pull the heroku db to my local and also push my db to the heroku remote. Locally I have MYSQL and in heroku it is Postgresql. I found lot ways suggested in internet but none seems to be working and most of them are very old and things have changed.

Things tried:


heroku db:push - didnt work

$ heroku db:push
 !    `db:push` is not a heroku command.
 !    Perhaps you meant `pg:push`.
 !    See `heroku help` for a list of available commands.

heroku pg:push : Here am not sure how to mention the source database (and i dont have a local db password)

$ heroku pg:push mysql://root:@localhost/app_development --app myapp
Usage: heroku pg:push <SOURCE_DATABASE> <REMOTE_TARGET_DATABASE>

 push from SOURCE_DATABASE to REMOTE_TARGET_DATABASE
 REMOTE_TARGET_DATABASE must be empty.

 SOURCE_DATABASE must be either the name of a database
 existing on your localhost or the fully qualified URL of
 a remote database.

Info:


$ heroku version
heroku-toolbelt/3.37.0 (x86_64-linux) ruby/2.2.1
You have no installed plugins.

OS : Ubuntu 14.04

$ heroku pg:info --app myapp
=== DATABASE_URL
Plan:        Hobby-dev
Status:      Available
Connections: 1/20
PG Version:  9.4.1
Created:     2015-05-16 07:05 UTC
Data Size:   6.7 MB
Tables:      6
Rows:        0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback:    Unsupported

2 Answers 2

1

You cannot push a MySQL to PG, as snkashis said. But assuming you've migrated your data to a postgres db, there are two things you need to add to the heroku pg:push, command, which is your local database name and your database on heroku. To get the name of your heroku databases, type the following into your console:

$heroku pg

and you should see an output like the following:

=== HEROKU_POSTGRESQL_GREEN_URL, DATABASE_URL
Plan:               Standard 0
Status:             Available
Data Size:          x.xx GB
Tables:             83
PG Version:         9.4.1
Connections:        8/120
Fork/Follow:        Available
Rollback:           earliest from 2015-08-08 21:07 UTC
Created:            2015-03-09 14:29 UTC
Maintenance:        not required
Maintenance window: Tuesdays 23:00 to Wednesdays 03:00 UTC
Add-on:             dozing-drolly-xxx

in this example, your DATABASE_URL would be HEROKU_POSTGRESQL_GREEN_URL

to get the name of your current, local database, from your postgres console type:

select current_database()

and you should get an output like:

  current_database
--------------------
 db_development
(1 row)

so now, your command would be:

heroku pg:push db_development HEROKU_POSTGRESQL_GREEN_URL

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

Comments

0

You cannot use pg:push from MySQL to PG. I would think the correct answer here would be to definitely switch your local development system to use Postgres to match your production environment..which has the potential to minimize many problems(including ones that haven't exposed themselves yet), not just this one. Heroku actually provides notes on a conversion utility for this, you can view the details at https://devcenter.heroku.com/articles/heroku-mysql.

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.