Multiple databases in Rails. Part 2: Heroku
If second database config is isolated in a separate file the way it was described in a previous post, then to make this work on Heroku it is required to set the environment variable with url to the database you want to use as second one. For instance, if you created a second database called HEROKU_POSTGRESQL_SECOND_DB_URL all you have to do is to set this database url’s value using the Heroku toolbelt:
And you’re ready to go. But this works only in cases when second database allows connections from all ip addresses. If database is placed behind the firewall or accepts only whitelisted IP addresses from
pg_hba.conf then additional steps would be required to setup SOCK proxy.
For instance, a SOCKS wrapper script is available as part of QuotaGuard Static add-on. Unfortunately, its wrapper script does not work with puma server and causing a deadlock in it. You may also try Proximo add-on
Add-on can be configured by prepending the call to the wrapper script in a
By default this wrapper routes all outbound TCP traffic via the proxy but there is additional configuration available to limit this to just your database traffic.
Originally published at slavakisel.github.io.