Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>UPDATED</strong></p> <p>Originally, this answer stated that although this was possible with a few tricks, it was <em>strongly</em> discouraged. This was based on advice on the Heroku developer support website. However, recently Heroku issued a communication specifically describing how to achieve this, and have watered down their advice on the developer site. The complete text of this section of their e-mail is included below:</p> <blockquote> <p>Did you know that Heroku apps can share a common database? For example, you can put analytics functions in a separate application from your user-facing code.</p> <p>Simply set the DATABASE_URL config var for several apps to the same value. First, get the DATABASE_URL for your existing app:</p> <pre><code>$ heroku config | grep DATABASE_URL --app sushi DATABASE_URL =&gt; postgres://lswlmfdsfos:5FSLVUSLLT123@ec2-123-456-78-90.compute1.amazonaws.com/ldfoiusfsf </code></pre> <p>Then, set the DATABASE_URL for new apps to this value:</p> <pre><code>$ heroku config:add DATABASE_URL=postgres://lswlmfdsfos:5FSLVUSLLT123@ec2-123-456-78-90.compute-1.amazonaws.com/ldfoiusfsf --app sushi-analytics Adding config vars: DATABASE_URL =&gt; postgres://lswlm...m/ldfoiusfsf Restarting app... done, v74. That's it </code></pre> <p>— now both apps will share one database.</p> </blockquote> <p>Just as a point of reference, Heroku's original advice was to create and use an API to access data remotely. My personal view is that overall, for many situations this is <em>good advice</em>, (i.e. better than just connecting multiple application to the same DB) although I can see situations where that'd be more trouble than it's worth.</p> <p><strong>UPDATE</strong></p> <p>As per comments on this answer, it's worth noting that Heroku do reserve the right to change database URLs as required. If this occurs, it will cause your secondary connections to fail, and you'll need to update the URLs accordingly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload