Multi-Database Support Limitations #183
Replies: 5 comments 14 replies
|
Not to distract from your issue, but I am quite interested in this as I think using Solid gems like SolidCache also suffers from a similar issue. As when using SolidCache you may be using multiple database under the cannot swap `shard` while shard swapping is prohibited. |
|
@miguelmarcondesf Thanks for asking this question!
This is not something I've attempted to do myself. The database connections should mostly work, but the Rails integrations controlled by setting I'm deeply curious about this use case -- generally speaking, what are the shear zones? For example, I can imagine that Action Cable integration would be affined with the But I have no idea what Active Storage should do here, since obviously there are going to be some blobs associated with the user (e.g., avatars) and some blobs associated with the patient (e.g., x-rays). Have you thought through how you want that to behave? My recommendation to you is to set |
|
I came here because I'm wondering if I can use ActionText and Active Storage in Global and in a Tenant context. But Gemspec and other bits in the code tells me "nope." |
|
As it turns out, I have a need to have multiple tenanted databases in the app I'm working on, and so I expect to do a lot of learning shortly about the current constraints of Rails and Active Record Tenanted, and maybe what can be changed to better support this use case. |
|
I've just come across this thread which seems to address my use. I have one database that is shared, it basically stores user information. When a new user is created I have a
From reading everything here it seems what I want to do isn't possible at the moment. Is that the case? Thanks in advance :-) |
Uh oh!
There was an error while loading. Please reload this page.
Hello there!
I'm doing some studies and experiments with multi-database setups, and I stumbled upon some limitations and conflicts when trying to use multiple tenanted connection classes, which I think are expected for now.
Use Case
Healthcare management system requiring:
My database config:
What I Tried
Manual Tenant Synchronization
Being called on
active_record_tenanted.tenant_resolverExpected result: cannot swap sharp while shard swapping is prohibited
Custom Middleware
Expect Result: Same shard swapping prohibition
Connection Override
expected Result: Circular dependencies and shard swapping errors
Rails connects_to + activerecord-tenanted
Expected Result: Conflicts between gems tenant switching and native multi-database
Other problems
Migration Management
Final Workaround
For now, to continue digging the gem, I just migrated things from the second tenanted database to the primary one
Suggested Improvements
Multi-Connection Support
Helping with handling the context switching and correctly finding migrations
Thank you in advance and let me know if it makes sense
All reactions