Enforce proper use of Shared Models
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
In !68795 (merged) we're introducing the concept of SharedModel which lets a model talk to multiple databases by overriding the connection.
There's two downsides to this:
- we don't enforce usage of
SharedModelfor models that need cross-database support - we don't enforce that we use a non-default connection in the presence of multiple databases
We should reconsider reorganizing all similar models into a single location (by convention) so we can use a cop to enforce use of SharedModel as a base class.
It's possible we can also add a check in SharedModel to ensure we don't use the default connection when multiple databases are present, but this might be tricky since we use them in contexts where that might be okay (migrations).
Edited by 🤖 GitLab Bot 🤖