Skip to content

Rubocop rule to prevent AR::Base.connection [RUN AS-IF-FOSS]

Description of the proposal

The groupsharding plans to decompose some parts of the GitLab application's database. To support this effort we want to introduce different ApplicationRecord base classes pointing to different database servers.

This rubocop rule prevents calling methods on ActiveRecord::Base and suggests using ApplicationRecord. I added a documentation page about the usage of transactions and how it affects the decompositon and sharding efforts. It's pretty basic for now. I expect that this document will grow as we move forward with our work on the CI tables.

The MR adds all the offenses to the .rubocop_manual_todo.yml file, I'll fix them in a follow-up issue: #335192 (closed)

Check-list

  • Make sure this MR enables a static analysis check rule for new usage but ignores current offenses
  • Mention this proposal in the relevant Slack channels (e.g. #development, #backend, #frontend)
  • The MR doesn't have significant objections, and is getting a majority of 👍 vs 👎 (remember that we don't need to reach a consensus)
  • (If applicable) One style is getting a majority of vote (compared to the other choice)
  • (If applicable) Update the MR with the chosen style
  • Create a follow-up issue to fix the current offenses as a separate iteration: ISSUE_LINK
  • Follow the review process as usual
  • Once approved and merged by a maintainer, mention it again:
    • In the relevant Slack channels (e.g. #development, #backend, #frontend)
    • (Optional depending on the impact of the change) In the Engineering Week in Review

/cc @gitlab-org/maintainers/rails-backend

Edited by Adam Hegyi

Merge request reports

Loading