forked from rails-on-services/apartment
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rails-on-services#243 from eraffel-MDSol/development
Support Rails 7.1, drop Ruby 2.x and Rails < 6.1
- Loading branch information
Showing
21 changed files
with
72 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.7.7 | ||
3.1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "http://rubygems.org" | ||
|
||
gem "rails", "~> 7.1.0" | ||
|
||
platforms :ruby do | ||
gem "sqlite3", "~> 1.6" | ||
end | ||
|
||
platforms :jruby do | ||
gem "activerecord-jdbc-adapter", "~> 61.0" | ||
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0" | ||
gem "activerecord-jdbcmysql-adapter", "~> 61.0" | ||
end | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord # :nodoc: | ||
if ActiveRecord::VERSION::MAJOR >= 6 | ||
# This is monkeypatching Active Record to ensure that whenever a new connection is established it | ||
# switches to the same tenant as before the connection switching. This problem is more evident when | ||
# using read replica in Rails 6 | ||
module ConnectionHandling | ||
def connected_to_with_tenant(role: nil, prevent_writes: false, &blk) | ||
current_tenant = Apartment::Tenant.current | ||
# This is monkeypatching Active Record to ensure that whenever a new connection is established it | ||
# switches to the same tenant as before the connection switching. This problem is more evident when | ||
# using read replica in Rails 6 | ||
module ConnectionHandling | ||
def connected_to_with_tenant(role: nil, prevent_writes: false, &blk) | ||
current_tenant = Apartment::Tenant.current | ||
|
||
connected_to_without_tenant(role: role, prevent_writes: prevent_writes) do | ||
Apartment::Tenant.switch!(current_tenant) | ||
yield(blk) | ||
end | ||
connected_to_without_tenant(role: role, prevent_writes: prevent_writes) do | ||
Apartment::Tenant.switch!(current_tenant) | ||
yield(blk) | ||
end | ||
|
||
alias connected_to_without_tenant connected_to | ||
alias connected_to connected_to_with_tenant | ||
end | ||
|
||
alias connected_to_without_tenant connected_to | ||
alias connected_to connected_to_with_tenant | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.