Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you run the heroku console on a follower DB?

I have a ruby on rails app deployed on heroku with a database and a follower database.

I typically do "heroku run rails console" to look around the data, and I'm wondering if there's a way that I can do it on the follower database so I don't accidentally write/delete things. I know this should be simple, but I couldn't seem to find documentation on it.

Thanks!

like image 756
David Avatar asked Sep 27 '13 02:09

David


1 Answers

You can do this from your local console. Just fire it up:

rails console

Then you need the connection information for your follower database on heroku. You can retrieve this from https://postgres.heroku.com/databases/. Just click the relevant database and assign a hash with the following info:

follower_db = {:adapter  => "postgresql",
 :host     => "myhost",
 :username => "myuser",
 :password => "mypass",
 :database => "somedatabase"}

Now connect to this remote database from the console:

ActiveRecord::Base.establish_connection(follower_db)

Now any query you enter in the console will be run on this DB.

like image 142
pejmanjohn Avatar answered Oct 06 '22 21:10

pejmanjohn