Mark the replicas as replicas
Rails won't even attempt to write to a replica. Without this option, a write attempt would actually run against Postgres, and it would be up to Postgres to throw a readonly error. Additionally, marking it as a replica teaches ActiveRecord that it should not attempt to run migrations against this connection. https://api.rubyonrails.org/classes/ActiveRecord/DatabaseConfigurations.html#method-i-configs_for I'm actually pretty sure that the lack of `replica: true` is why there's currently a db/slave1_schema.rb and db/slave2_schema.rb
This commit is contained in:
parent
903b6c7969
commit
f472a6154e
|
@ -13,9 +13,11 @@ development:
|
||||||
slave1:
|
slave1:
|
||||||
<<: *default
|
<<: *default
|
||||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||||
|
replica: true
|
||||||
slave2:
|
slave2:
|
||||||
<<: *default
|
<<: *default
|
||||||
url: <%= ENV['DB_SLAVE2_URL'] %>
|
url: <%= ENV['DB_SLAVE2_URL'] %>
|
||||||
|
replica: true
|
||||||
|
|
||||||
# Warning: The database defined as "test" will be erased and
|
# Warning: The database defined as "test" will be erased and
|
||||||
# re-generated from your development database when you run "rake".
|
# re-generated from your development database when you run "rake".
|
||||||
|
@ -43,6 +45,8 @@ production:
|
||||||
slave1:
|
slave1:
|
||||||
<<: *default
|
<<: *default
|
||||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||||
|
replica: true
|
||||||
slave2:
|
slave2:
|
||||||
<<: *default
|
<<: *default
|
||||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||||
|
replica: true
|
||||||
|
|
Loading…
Reference in New Issue