Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when having multiple databases with tables with the same name. #100

Open
serch opened this issue Aug 12, 2020 · 3 comments
Open

Issue when having multiple databases with tables with the same name. #100

serch opened this issue Aug 12, 2020 · 3 comments
Labels

Comments

@serch
Copy link
Contributor

serch commented Aug 12, 2020

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

@gurkanindibay
Copy link
Contributor

@serch Could you write a test case for this scenario? It is rather complex.

@gurkanindibay
Copy link
Contributor

We need to create some tests for multiple databases scenario to prioritize it

@serch
Copy link
Contributor Author

serch commented May 4, 2023

@gurkanindibay I'm really sorry but I can't, I'm swamped atm 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants