Skip to content

Commit

Permalink
Add support for Rails 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrage committed Nov 25, 2024
1 parent 251e0c9 commit 9ea15ca
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 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
5 changes: 5 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ end
appraise "rails-7.2" do
gem "rails", "7.2.2"
end

appraise "rails-8.0" do
gem "rails", "8.0.0"
gem "relation_to_struct", github: "rkrage/relation_to_struct", branch: "rails-8"
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

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

source "https://rubygems.org"

gem "rails", "8.0.0"
gem "relation_to_struct", branch: "rails-8", git: "https://github.com/rkrage/relation_to_struct"

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 9ea15ca

Please sign in to comment.