Rosa Gutierrez
Rosa Gutierrez
@hubertjakubiak so sorry for the delay! I did look into it but was immediately pulled into other directions before I could figure out anything, but this is definitely high on...
Hey @hubertjakubiak, @thibaudgg, @bubiche, I'm back again with something I did find back then, and that just revisited... and it was that things work fine as long as you don't...
@thibaudgg good point! I think in that case, [you could rely on `ActiveRecord::Base.connected_to_many`](https://api.rubyonrails.org/classes/ActiveRecord/ConnectionHandling.html#method-i-connected_to_many), with both your `ApplicationRecord` and `ActiveStorage::Record`. Something like ```ruby ActiveRecord::Base.connected_to_many(ApplicationRecord, ActiveStorage::Record, role: :writing, shard: tenant.to_sym) do yield...
Ohhhh, great point @robacarp. Thanks a lot for sharing that. Going to read that carefully and the forum thread linked there. It seems this area has still some open questions...
Hmm... wait, @robacarp, I think your example above would be expected in any case, if you have different models with different DB configurations 🤔 It could be written like: ```ruby...
Ahhhh! Thanks for the extra explanation, that makes sense 🙏 No problem at all with going off-topic, this was super helpful for me as I try to figure out the...
> I assume this is happening because you can’t connect to the same SQLite database twice in the same thread, once through `ApplicationRecord` and another time through `ActiveStorage::Record` Ohh, interesting!...
Yes, it's strange! I think this should have gotten a different error, but [have you tried increasing Active Record's pool size](https://github.com/csa-admin-org/csa-admin/blob/442f0b6f82baeecd82c54d6d6c8f42c935750bab/config/database.yml#L3)?
> Are you confident that having twice the same SQLite DB (with the `:writing` role) in the `connected_to_stack` array is supported? Nope, not confident, it seems it should work just...
Ok, I've tested this with Active Storage in a new app and it seems to be working fine 🤔 I have two shards: ```yml development: shard_one: select * from active_storage_blobs;...