Skip to content

Backport `disable_joins` to enable usage of cross-DB relations

As part of identified changes of PoC is to backport support for disable_joins. disable_joins allows to mark passthrough relations as having to use pluck instead of cross-joins. This is essential if the relation defines a model living in another DB.

class Runner
   has_many :projects, through: :runner_projects, disable_joins: true
end

Related:

Proposal

  1. Backport disable_joins in a vanila way: 1-to-1 change
  2. Since usage of disable_joins might have negative impact we need have a way to dynamically toggle the feature to validate this on production
  3. Add additional (temporary feature) on top of disable joins to allow this to by feature-flagged (this should be done on top of backport, the best as an additional mixin). We should remove it as soon as possible as no longer needed.
class Runner
   # allow to feature flag disable join usage to rollout it to the production as it might
   has_many :projects, through: :runner_projects, disable_joins: -> { Feature.enabled?(:ci_runner_projects_disable_joins) }
end
Edited by Kamil Trzciński