Heroku – connect to different database and transfer data to current environment

If you run into a situation where you’ve been developing an application in a live heroku development environment and have entered a substantial amount of live data that you don’t want to reenter into your live production environment, then connecting to your development instance’s database and retrieving the specific data you are interested in might help. To do this, you can use the following snippet within your production environment’s console:

:adapter => "postgresql",
:port =>5432,

This will allow you to interact with the staging environment within your production console to retrieve specific data. You can then reconnect to your current environment’s DB with the following snippet:

ActiveRecord::Base.establish_connection :production

Where you can then use the data you just retrieved to update your production models.

Leave a Reply

Your email address will not be published. Required fields are marked *