citusdata / citusdata/activerecord-multi-tenant
Issue when having multiple databases with tables with the same name.
- Dominant language
- Ruby
- Stars
- 759
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
There is an issue when having multiple databases with tables with the same name.
The case I experienced is the following: I have 2 databases, the main postgres database that uses the citus extension, and a smaller sqlite db. There are some tables in both databases that have the same name.
I set up Active Record 6 to work with both databases and I use the multi-tenant extension in the main db. When I try to delete a record in the sqlite db the multi-tenant gem picks the model from the main db (that has a table with the same name) and inserts the tenant clause causing the query to fail.
I believe this comes from the fact that the multi tenant models are stored in a hash indexed by table name https://github.com/citusdata/activerecord-multi-tenant/blob/master/lib/activerecord-multi-tenant/multi_tenant.rb#L27-L30
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.