-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Rails 7.1, drop Ruby 2.x and Rails < 6.1 #243
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,11 +3,9 @@ version: 2.1 | |||||
jobs: | ||||||
build: | ||||||
docker: | ||||||
- image: << parameters.ruby_version >> | ||||||
- image: postgres:11.19-alpine | ||||||
environment: | ||||||
POSTGRES_HOST_AUTH_METHOD: "trust" | ||||||
- image: mysql:5.7 | ||||||
- image: cimg/<< parameters.ruby_version >> | ||||||
- image: cimg/postgres:12.13 | ||||||
- image: cimg/mysql:8.0 | ||||||
environment: | ||||||
MYSQL_ALLOW_EMPTY_PASSWORD: "yes" | ||||||
parameters: | ||||||
|
@@ -19,31 +17,16 @@ jobs: | |||||
BUNDLE_GEMFILE: << parameters.gemfile >> | ||||||
steps: | ||||||
- checkout | ||||||
# Restore Cached Dependencies | ||||||
# - restore_cache: | ||||||
# keys: | ||||||
# - gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "<< parameters.gemfile >>.lock" }} | ||||||
# - gem-cache-v1-{{ arch }}-{{ .Branch }} | ||||||
# - gem-cache-v1 | ||||||
|
||||||
- run: bundle install --path vendor/bundle | ||||||
|
||||||
# - save_cache: | ||||||
# key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "<< parameters.gemfile >>.lock" }} | ||||||
# paths: | ||||||
# - vendor/bundle | ||||||
|
||||||
- run: | ||||||
name: Update apt | ||||||
command: apt update -y | ||||||
command: sudo apt update -y | ||||||
|
||||||
- run: | ||||||
name: Install dependencies | ||||||
command: apt install -y curl postgresql-client default-mysql-client | ||||||
|
||||||
- run: | ||||||
name: Install dockerize | ||||||
command: curl -sfL $(curl -s https://api.github.com/repos/powerman/dockerize/releases/latest | grep -i /dockerize-$(uname -s)-$(uname -m)\" | cut -d\" -f4) | install /dev/stdin /usr/local/bin/dockerize | ||||||
command: sudo apt install -y curl postgresql-client default-mysql-client | ||||||
|
||||||
- run: | ||||||
name: Configure config database.yml | ||||||
|
@@ -75,12 +58,5 @@ workflows: | |||||
- build: | ||||||
matrix: | ||||||
parameters: | ||||||
ruby_version: ["ruby:2.7-buster", "ruby:3.0-buster", "ruby:3.1-buster", "ruby:3.2-buster"] | ||||||
gemfile: ["gemfiles/rails_5_2.gemfile", "gemfiles/rails_6_0.gemfile", "gemfiles/rails_6_1.gemfile", "gemfiles/rails_7_0.gemfile"] | ||||||
exclude: | ||||||
- ruby_version: "ruby:3.0-buster" | ||||||
gemfile: "gemfiles/rails_5_2.gemfile" | ||||||
- ruby_version: "ruby:3.1-buster" | ||||||
gemfile: "gemfiles/rails_5_2.gemfile" | ||||||
- ruby_version: "ruby:3.2-buster" | ||||||
gemfile: "gemfiles/rails_5_2.gemfile" | ||||||
ruby_version: ["ruby:3.1.4", "ruby:3.2.2"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
gemfile: ["gemfiles/rails_6_1.gemfile", "gemfiles/rails_7_0.gemfile", "gemfiles/rails_7_1.gemfile"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.7.7 | ||
3.1.4 |
This file was deleted.
This file was deleted.
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: "../" |
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this method should be implemented as such:
Potentially There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing this method would be out of the scope of my PR, which is just to get Rails 7.1 supported. The only reason there's changes in this file is I got rid of the |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord | ||
class SchemaMigration < ActiveRecord::Base # :nodoc: | ||
class SchemaMigration # :nodoc: | ||
class << self | ||
def table_exists? | ||
connection.table_exists?(table_name) | ||
Comment on lines
+4
to
7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this monkey-patch needs to be removed as it breaks rails 7.1 support def table_exists?
@pool.with_connection do |connection|
connection.data_source_exists?(table_name)
end
end it's almost identical - the main difference is that it uses # Checks to see if the data source +name+ exists on the database.
#
# data_source_exists?(:ebooks)
#
def data_source_exists?(name)
query_values(data_source_sql(name), "SCHEMA").any? if name.present?
rescue NotImplementedError
data_sources.include?(name.to_s)
end
# Checks to see if the table +table_name+ exists on the database.
#
# table_exists?(:developers)
#
def table_exists?(table_name)
query_values(data_source_sql(table_name, type: "BASE TABLE"), "SCHEMA").any? if table_name.present?
rescue NotImplementedError
tables.include?(table_name.to_s)
end so basically just I believe this monkey-patch needs to be removed, this will 100% cause errors on rails 7.1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a failing test I can add then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this was added because |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.