influitive / apartment

Database multi-tenancy for Rack (and Rails) applications
2.67k stars 463 forks source link

Overwrites database name with tenant name key. #541

Open parkeryoung opened 6 years ago

parkeryoung commented 6 years ago

I'm looking to implement this gem to overwrite some of our old database switching to help in updating rails.

We have some read databases and are used in certain cases and I am defining them as a part of the sharding support for this gem. The database names are the same as the write database names so to make the distinction between the read and write database connections I was putting something like database_1_slave instead of just database_1 as the key for the hash I am defining in the tenant_names block.

It appears as though in the multi_tenantify method it will call the multi_tenantify_with_tenant_db_name method and uses the key (the tenant variable) as the database value in the hash. It will not do this if the with_database option is false. However there is no way to set this as an option when calling the switch or as some kind of configuration option.

Can anyone give me any insights as to why this was done? Potential work-arounds? How to edit the project in order to make the with_database option configurable in some way?