Amokrane Chentir
Amokrane Chentir

Reputation: 30385

Dedicated database sharing between two apps on Heroku

I have two apps on Heroku and I would like them to use the same dedicated database. The problem is that this new app has the same models/tables than the other one.

My questions are:

Any good advices on how to do this will be appreciated.

Thanks!

Upvotes: 2

Views: 496

Answers (1)

Kevin Bedell
Kevin Bedell

Reputation: 13404

In general this is probably not as good an idea as it may seem. Rails is designed to assume it has 100% control over the database.

Even if you are able to get your tables separated and not colliding, you will still have challenges with the schema_migrations table. That table holds all the migrations for rails and would contain a mix of all migration records for both applications. This would confuse the apps whenever, for example, you tried to run rake db:rollback or other rake commands.

There could also be issues with having your schema.rb file potentially get out of synch between the two applications.

I'd recommend looking hard at the reasons you want to share the database and see if there are other ways to accomplish what you are trying to do. For example, you might consider using Active Resources to connect the applications restfully.

Upvotes: 2

Related Questions