0

I've popped into console and ran the "heroku addons:add mongohq:free" which added an environment variable: ENV['MONGOHQ_URL']. It is a url that looks like this:

mongodb://heroku:xxxxxxxxxxxxxxxxxxxxxxxxx@staff.mongohq.com:10059/appxxxxxx

I want to be able to use (and share) TWO mongodb instances. Running addons:add mongohq:free on the same app fails saying that the addon is already present.

Do I have to create a separate, blank app and just use the ENV variable from it?

Finally, is it possible to share these urls between apps?

dsp_099
  • 5,801
  • 17
  • 72
  • 128

1 Answers1

1

To have multiple Mongo instances, you can either: * Create another account on MongoHQ or another provider * Create your own server and install mongo on it with authentication and multiple DBs

You then would need to add environmental variables for as many mongo DB's as you want.

Then, your application would need to know which MongoDB to connect to, under whichever circumstances are applicable in your app.

Note: you can replace Mongo with Postgres or MySQL above and its the exact same procedure.

And yes, you can share these between apps -- simple set the environment variable to match and you're good to go.

Jesse Wolgamott
  • 40,197
  • 4
  • 83
  • 109