This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2023-07-12 08:06:00 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DatabaseHelper
|
|
|
|
def with_read_replica(&block)
|
2023-07-16 23:26:52 -07:00
|
|
|
ApplicationRecord.connected_to(role: :reading, prevent_writes: true, &block)
|
2023-07-12 08:06:00 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def with_primary(&block)
|
2023-07-16 23:26:52 -07:00
|
|
|
ApplicationRecord.connected_to(role: :writing, &block)
|
2023-07-12 08:06:00 -07:00
|
|
|
end
|
|
|
|
end
|