Skip to content
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

Add support for Rails 8.0 #111

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
- 15
- 16
ruby:
- "3.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment from here: jcoleman/relation_to_struct#23 (comment)

The other versions of Rails still support 3.1 but it was much easier to just remove it completely instead of special-casing Rails 8. I think this should be fine as Ruby 3.1 is EOL in 4 months?

- "3.2"
- "3.3"
gemfile:
- rails_7.0
- rails_7.1
- rails_7.2
- rails_8.0
name: PostgreSQL ${{ matrix.pg }} - Ruby ${{ matrix.ruby }} - ${{ matrix.gemfile }}
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
Expand Down
10 changes: 7 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
appraise "rails-7.0" do
gem "rails", "7.0.8"
gem "rails", "~> 7.0.0"
end

appraise "rails-7.1" do
gem "rails", "7.1.5"
gem "rails", "~> 7.1.0"
end

appraise "rails-7.2" do
gem "rails", "7.2.2"
gem "rails", "~> 7.2.0"
end

appraise "rails-8.0" do
gem "rails", "~> 8.0.0"
end
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in pg_ha_migrations.gemspec
gemspec

2 changes: 1 addition & 1 deletion gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "7.0.8"
gem "rails", "~> 7.0.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "7.1.5"
gem "rails", "~> 7.1.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "rails", "7.2.2"
gem "rails", "~> 7.2.0"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 8.0.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/pg_ha_migrations/allowed_versions.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "active_record/migration/compatibility"

module PgHaMigrations::AllowedVersions
ALLOWED_VERSIONS = [4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2].map do |v|
ALLOWED_VERSIONS = [4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0].map do |v|
begin
ActiveRecord::Migration[v]
rescue ArgumentError
Expand Down
2 changes: 1 addition & 1 deletion pg_ha_migrations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "pry-byebug"
spec.add_development_dependency "appraisal", "~> 2.5"

spec.add_dependency "rails", ">= 7.0", "< 7.3"
spec.add_dependency "rails", ">= 7.0", "< 8.1"
spec.add_dependency "relation_to_struct", ">= 1.5.1"
spec.add_dependency "ruby2_keywords"
end
15 changes: 13 additions & 2 deletions spec/safe_statements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2708,7 +2708,13 @@ def up

it "doesn't acquire a lock which prevents concurrent reads and writes" do
alternate_connection_pool = ActiveRecord::ConnectionAdapters::ConnectionPool.new(pool_config)
alternate_connection = alternate_connection_pool.connection

# The #connection method was deprecated in Rails 7.2 in favor of #lease_connection
alternate_connection = if alternate_connection_pool.respond_to?(:lease_connection)
alternate_connection_pool.lease_connection
else
alternate_connection_pool.connection
end

alternate_connection.execute("BEGIN")
alternate_connection.execute("LOCK TABLE foos")
Expand Down Expand Up @@ -4069,7 +4075,12 @@ def up
ActiveRecord::ConnectionAdapters::ConnectionPool.new(pool_config)
end
let(:alternate_connection) do
alternate_connection_pool.connection
# The #connection method was deprecated in Rails 7.2 in favor of #lease_connection
if alternate_connection_pool.respond_to?(:lease_connection)
alternate_connection_pool.lease_connection
else
alternate_connection_pool.connection
end
end
let(:migration) { Class.new(migration_klass).new }

Expand Down