aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEileen Uchitelle <eileencodes@gmail.com>2018-08-30 16:49:13 -0400
committerEileen Uchitelle <eileencodes@gmail.com>2018-08-31 10:52:32 -0400
commit2fd997c111b3d2921d011d8023314dbfc2dec317 (patch)
treeeeb676810b4819c5f49e3d9f0b0d29c4f90daf6a /activerecord
parent8f2caec401c8e97d9eb1ea84d8263911c50e1ed6 (diff)
downloadrails-2fd997c111b3d2921d011d8023314dbfc2dec317.tar.gz
rails-2fd997c111b3d2921d011d8023314dbfc2dec317.tar.bz2
rails-2fd997c111b3d2921d011d8023314dbfc2dec317.zip
Add config option for `replica`.
This allows the user to add `replica: true` to the database config to signify the connection should be treated as readonly. This will be useful so we can ignore structure dumps or migrations (or creating / deleting etc) the readonly connection for the databases. These are paired with a write database which is where the create/drop/migrate should be run. This allows us to ask the connection if it's for a replica readonly db or a primary write db.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 8999d3232a..a62651daff 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -127,6 +127,10 @@ module ActiveRecord
)
end
+ def replica?
+ @config[:replica] || false
+ end
+
def migrations_paths # :nodoc:
@config[:migrations_paths] || Migrator.migrations_paths
end