You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this gem doesn't support multiple databases and you have to explicitly call TenantLevelSecurity.switch! when connecting other databases. But this is obviously inconvenient in read replicas.
One possible solution is that TenantLevelSecurity.switch! switches all connections on the current thread. This can be implemented by referring to AcitveRecord::Base.clear_query_caches_for_current_thread. See also rails/rails#35089
Note that some versions have different ways of getting the connection pool.
Another solution is to add a hook that fires when connecting to another database and run TenantLevelSecurity.switch! there. This is close to the current design of switching tenants using checkout callbacks, but I'm not sure if the same way works for multiple databases.
The text was updated successfully, but these errors were encountered:
See also #12
See also #13
Currently this gem doesn't support multiple databases and you have to explicitly call
TenantLevelSecurity.switch!
when connecting other databases. But this is obviously inconvenient in read replicas.One possible solution is that
TenantLevelSecurity.switch!
switches all connections on the current thread. This can be implemented by referring toAcitveRecord::Base.clear_query_caches_for_current_thread
. See also rails/rails#35089Note that some versions have different ways of getting the connection pool.
Another solution is to add a hook that fires when connecting to another database and run
TenantLevelSecurity.switch!
there. This is close to the current design of switching tenants using checkout callbacks, but I'm not sure if the same way works for multiple databases.The text was updated successfully, but these errors were encountered: