Multi-Database Support Limitations #183
Replies: 2 comments 4 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. |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
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_resolver
Expected 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
Beta Was this translation helpful? Give feedback.
All reactions