From d6fae56d3fc70da57a7b23ea73042febe0dcadb3 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 21 Jul 2023 11:30:53 +0200 Subject: [PATCH] Fix replica being used even if not explicitly defined (#26074) --- app/models/application_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 23e0af3a2a..efff5cdad5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -5,7 +5,7 @@ class ApplicationRecord < ActiveRecord::Base include Remotable - connects_to database: { writing: :primary, reading: :read } + connects_to database: { writing: :primary, reading: ENV['DB_REPLICA_NAME'] || ENV['READ_DATABASE_URL'] ? :read : :primary } class << self def update_index(_type_name, *_args, &_block)