thiagopradi / octopus

Database Sharding for ActiveRecord
2.53k stars 505 forks source link

Read slave doesn't work with non-public postgres schema #296

Open mingc opened 9 years ago

mingc commented 9 years ago

Hi,

We're using the apartment gem https://github.com/influitive/apartment to implement multi-tenant database. When I test a the read slave, I found octopus' replicated_model doesn't read from the tenant postgres schema (only public schema).

Apartment::Tenant.switch('tenant1') Dummy.create(name: 'test1') Dummy.all -> return empty Dummy.using(:master).all -> return correct data

Is there way to get octopus to read from slave db's tenant schema? Thanks.

sobrinho commented 8 years ago

I'm not sure how you are using apartment + octopus, they don't do the same thing?

fdc263 commented 8 years ago

Apartment make it possible the app use multiple schemas on same database Octopus make it possible the app use multiple databases. They are different things, right?

Apartment + Octopus would be useful.

cransom commented 7 years ago

I happened to run into this now. We use Apartment to segregate tenants into different schemas (this is postgresql parlance) of the database for data segregation and are looking into Octopus to decouple reads and writes to send them to different databases.