I wonder if there is some interest in supporting master-slave schema natively in rails, with the usual approach: convention over configuration. I am about to explore how to implement it on the rails core, but I'd love to know if there is some interest in it.
I think it would be great to have native support for this (without third party dependencies), in which you could configure in your database.yml the master database, and the read-only set of databases. That way rails could connect to one or another depending on what needs to be executed. If there is no read-only configuration specified, we'd assume that the schema is one master database only, and everything would work as nowadays.
Thanks for all your work.
Rafael Fernández López.
PS: I am close to find the time to start helping on github issues before/while working on this.
In the last version our approach for new features was to write external gems before integrating to Rails repository. I personally like the idea of having support for master-slave in Rails but in my opinion it should grow up first as a gem.
If the community embrace that gem and it show useful for the most part of application we can integrate it on the Rails repository.
This project for example was created as part of the Google Summer of Code project for the Rails organization and have support for master-slave but never was integrated in Rails repository, but in my opinion we don’t need to.
I find it great the idea of creating an external gem and integrate it to the core later on. I understand that not everything can go inside the core, but multiple database support (master-slaves) looks like something really important the core could have without installing external gems.
I have been reading on this matter, and octopus looks nice, but what I actually want to avoid is this kind of API:
User.where(:name => "Thiago").limit(3).using(:slave_one)
I'd love to map internally to one or another database (master or any read-only replication) depending _on what the query will be_. This way you don't have to mess with this kind of calls and everything happens in a transparent way. So, the final sql query involves read only queries, then we can safely access any of the replicas, however, if it involves any creation, deletion or modification, it will connect to the master one.
That's pretty much exactly what replication in octupus does: