Disable rails legacy_connection_handling
Set config.active_record.legacy_connection_handling
to false. We need this to be false so we can use specific connection handler for both vertical, and horizontal sharding.
Otherwise we get this error:
[1] pry(main)> Ci::ApplicationRecord.connected_to(role: :reading) { Ci::Pipeline.first }
NotImplementedError: `connected_to` can only be called on ActiveRecord::Base with legacy connection handling.
from /Users/tkuah/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activerecord-6.1.3.1/lib/active_record/connection_handling.rb:142:in `connected_to'
Proposal
Follow https://edgeguides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling, possibly need ENV VAR to migrate with production change management
- Add support to disable rails legacy_connection_handling
✅ - Roll this out to production - gitlab-com/gl-infra/production#4885 (closed)
✅ - If no adverse effects, remove ENABLE_RAILS_61_CONNECTION_HANDLING, and disable by default => !65107 (merged)
Risk
If you turn off legacy_connection_handling in your application, any method that's unsupported will raise an error (i.e. connection_handlers=).
Confidence level 80%
Edited by Thong Kuah