Is there any support for multiple databases in Rails 3? Either natively through ActiveRecord or third party gem?
Thanks.
Is there any support for multiple databases in Rails 3? Either natively through ActiveRecord or third party gem?
Thanks.
trung wrote:
Is there any support for multiple databases in Rails 3? Either natively through ActiveRecord or third party gem?
I haven't looked at Rails 3 yet but since being able to access
multiple databases is a core feature of Rails 1 and Rails 2 I feel
confident in saying that if Rails 3 didn't have it then it would be a
regression and therefore very unlikely. ![]()
Bob
If you mean can rails connect to different db's like mysql, oracle, etc, then the answer is yes, but my guess is that you are asking if there is support to connect your app to different schema's.
I'd like to know this too. My app has a master database, and then each customer has their own schema that contains their specific data. We had to jump through some hoops to make it work in rails so hopefully there is something in rails 3 to make life easier. I haven't been able to find any info on this so I'm guessing there isn't anything coming.
You guessed right. I want to connect to multiple schemas.
Like you said, we had to jump through hoops to get Rails 2 to work with multiple databases, especially with the schema migrations between multiple databases.
I see that there's a project called DBCharmer that solves all these problems for Rails 2. I wish we had known about it before. Unfortunately, DBCharmer doesn't work with Rails 3.
It would be awesome of Rails 3 addresses all the problems associated with using multiple databases out of the box.
jmamma wrote:
If you mean can rails connect to different db's like mysql, oracle, etc, then the answer is yes, but my guess is that you are asking if there is support to connect your app to different schema's.
I'd like to know this too. My app has a master database, and then each customer has their own schema that contains their specific data.
That's a bad idea. Generally speaking, all data should be in the same schema.
We had to jump through some hoops to make it work in rails
This is another example of Rails making bad things hard. Don't do bad things!
Best,
I don't think this is a bad idea at all. People just have different need.
For example, if you're building an eCommerce site.
You might want to clone the Catalog database that holds all static products information and deploy it on each front end app server. But all the app servers share a centralized Order database.
This is just one example, there are many other use cases for multiple databases...
Just because it's hard to do, doesn't mean it's a bad idea...
trung wrote:
I don't think this is a bad idea at all. People just have different need.
A database per customer is bad.
For example, if you're building an eCommerce site.
You might want to clone the Catalog database that holds all static products information and deploy it on each front end app server. But all the app servers share a centralized Order database.
Then you need clustering and replication support in the DB, not in Rails.
It obviously depends on your needs. We are connecting to multiple databases simply because we have to pull information from different systems. We have a main database where most Rails related data lives but we are also connecting to a second system which belongs to our PACS image storage system to pull information from it. Haven't tried out Rails 3 yet with multiple connections, initial tests showed some problems with it, but I will definitely come back to it and it is critical for us to get it working. Migrations were no issue for us since we were only reading from the PACS system.
Daniel