Skip to content

Commit

Permalink
Add support for Rails 8.0
Browse files Browse the repository at this point in the history
- Remove Ruby 3.1 from build matrix
  • Loading branch information
rkrage authored and jcoleman committed Nov 26, 2024
1 parent 251e0c9 commit f716287
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 12 deletions.
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"
- "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

0 comments on commit f716287

Please sign in to comment.