Skip to content

How to connect to a separate db? #382

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

Closed
shawn-zhuxy opened this issue Sep 13, 2021 · 5 comments
Closed

How to connect to a separate db? #382

shawn-zhuxy opened this issue Sep 13, 2021 · 5 comments
Assignees

Comments

@shawn-zhuxy
Copy link
Contributor

shawn-zhuxy commented Sep 13, 2021

Hi all;

I have found a same question in gitter but it did not be answered. So I have to ask again here.

I have a rails application that makes a connection to the different databases.
The model is like this:

# Bar Service
class Billing
   connects_to database: { writing: :foo_service, reading: :foo_service}
   has_closure_tree
end

Fetching records in Bar Service works fine. However, when I try to create an object it fails with: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "billing_hierarchies" does not exist.

I create billing_hierarchies in foo service, and I do not hope to create billing_hierarchies in bar service.
So is it a clean way to connect the closure tree to a separate db?

Thank you.

@seuros seuros self-assigned this Sep 13, 2021
@seuros
Copy link
Member

seuros commented Sep 14, 2021

This is an intersting bug. I will work a fix in the day.

Basically the hierarchy table should inherit the connection from the base table.

@shawn-zhuxy
Copy link
Contributor Author

Thanks for such a quick reply!

@shawn-zhuxy
Copy link
Contributor Author

shawn-zhuxy commented Sep 15, 2021

@seuros I have made some changes to the code for this issue. PTAL. Thank you. #384 The pr's author @shawndodo is myself.

@seuros
Copy link
Member

seuros commented Sep 17, 2021

@shawn-zhuxy , i will push a pre-release today.

@seuros seuros closed this as completed Sep 17, 2021
@shawndodo
Copy link
Contributor

@shawn-zhuxy , i will push a pre-release today.

Thank you!

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

No branches or pull requests

3 participants