2023-07-13 00:06:00 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DatabaseHelper
|
|
|
|
def with_read_replica(&block)
|
2023-07-17 15:26:52 +09:00
|
|
|
ApplicationRecord.connected_to(role: :reading, prevent_writes: true, &block)
|
2023-07-13 00:06:00 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def with_primary(&block)
|
2023-07-17 15:26:52 +09:00
|
|
|
ApplicationRecord.connected_to(role: :writing, &block)
|
2023-07-13 00:06:00 +09:00
|
|
|
end
|
|
|
|
end
|