Reputation: 30385
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:
Should I change the name for the tables on the new app?
If yes, what about the name of my models? Is it possible to map a model with a table with a different name? (Like User
model with new_user
table instead of user
).
Any good advices on how to do this will be appreciated.
Thanks!
Upvotes: 2
Views: 496
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