diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bbfaae..2edc7bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Appraisals b/Appraisals index 25e827e..94f198f 100644 --- a/Appraisals +++ b/Appraisals @@ -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 diff --git a/Gemfile b/Gemfile index 003d427..84e90a8 100644 --- a/Gemfile +++ b/Gemfile @@ -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 - diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index c86e7bc..9af0ae3 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "7.0.8" +gem "rails", "~> 7.0.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 0e56cd3..35a0ba3 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "7.1.5" +gem "rails", "~> 7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile index 247e05d..92cc2b2 100644 --- a/gemfiles/rails_7.2.gemfile +++ b/gemfiles/rails_7.2.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "7.2.2" +gem "rails", "~> 7.2.0" gemspec path: "../" diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile new file mode 100644 index 0000000..3b3765b --- /dev/null +++ b/gemfiles/rails_8.0.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 8.0.0" + +gemspec path: "../" diff --git a/lib/pg_ha_migrations/allowed_versions.rb b/lib/pg_ha_migrations/allowed_versions.rb index 06f194e..0e0cf17 100644 --- a/lib/pg_ha_migrations/allowed_versions.rb +++ b/lib/pg_ha_migrations/allowed_versions.rb @@ -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 diff --git a/pg_ha_migrations.gemspec b/pg_ha_migrations.gemspec index 07f5ef6..540b69e 100644 --- a/pg_ha_migrations.gemspec +++ b/pg_ha_migrations.gemspec @@ -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 diff --git a/spec/safe_statements_spec.rb b/spec/safe_statements_spec.rb index 172fca7..2fc35e0 100644 --- a/spec/safe_statements_spec.rb +++ b/spec/safe_statements_spec.rb @@ -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") @@ -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 }