Skip to content

Commit

Permalink
Add support for activerecord v7.2 (#126)
Browse files Browse the repository at this point in the history
Closes #124

Co-authored-by: Jon Jensen <jenseng@gmail.com>
  • Loading branch information
leoarnold and jenseng authored Sep 4, 2024
1 parent 879c7b8 commit f44787c
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
--health-retries 3
strategy:
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
gemfile: ["activerecord_6.1", "activerecord_7.0", "activerecord_7.1"]
ruby: ["3.1", "3.2", "3.3"]
gemfile: ["activerecord_6.1", "activerecord_7.0", "activerecord_7.1", "activerecord_7.2"]
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
Expand Down
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ appraise "activerecord-7.1" do
gem "racc", '~> 1.7.3', platforms: [:ruby_33]
end

appraise "activerecord-7.2" do
gem "activerecord", "~> 7.2.0"
gem "mysql2", "~> 0.5"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4.0"
gem "racc", '~> 1.7.3', platforms: [:ruby_33]
end

appraise "activerecord-edge" do
gem "arel", github: "rails/arel"
gem "activerecord", github: "rails/rails", :branch => "main"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source "https://rubygems.org"

gem "racc", "~> 1.7.3", platforms: [:ruby_33]
gem "activerecord", "~> 7.0.0"
gem "activerecord", "~> 7.1.0"
gem "mysql2", "~> 0.5"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4.0"
Expand Down
32 changes: 22 additions & 10 deletions gemfiles/activerecord_7.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,37 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
activemodel (7.1.3.4)
activesupport (= 7.1.3.4)
activerecord (7.1.3.4)
activemodel (= 7.1.3.4)
activesupport (= 7.1.3.4)
timeout (>= 0.4.0)
activesupport (7.1.3.4)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
base64 (0.2.0)
bigdecimal (3.1.8)
byebug (11.1.3)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
diff-lcs (1.5.0)
i18n (1.14.1)
drb (2.2.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
minitest (5.20.0)
minitest (5.25.0)
mutex_m (0.2.0)
mysql2 (0.5.5)
pg (1.5.4)
racc (1.7.3)
Expand All @@ -54,6 +65,7 @@ GEM
sexp_processor (4.17.0)
sqlite3 (1.4.4)
thor (1.3.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

Expand All @@ -62,7 +74,7 @@ PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 7.0.0)
activerecord (~> 7.1.0)
appraisal
byebug
hairtrigger!
Expand Down
21 changes: 21 additions & 0 deletions gemfiles/activerecord_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "racc", "~> 1.7.3", platforms: [:ruby_33]
gem "activerecord", "~> 7.2.0"
gem "mysql2", "~> 0.5"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4.0"

group :development do
gem "appraisal"
gem "byebug"
end

group :test do
gem "rake", "~> 13.0.6"
gem "rspec", "~> 3.12.0"
end

gemspec path: "../"
92 changes: 92 additions & 0 deletions gemfiles/activerecord_7.2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
PATH
remote: ..
specs:
hairtrigger (1.1.1)
activerecord (>= 6.0, < 8)
ruby2ruby (~> 2.4)
ruby_parser (~> 3.10)

GEM
remote: https://rubygems.org/
specs:
activemodel (7.2.0)
activesupport (= 7.2.0)
activerecord (7.2.0)
activemodel (= 7.2.0)
activesupport (= 7.2.0)
timeout (>= 0.4.0)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
base64 (0.2.0)
bigdecimal (3.1.8)
byebug (11.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
diff-lcs (1.5.1)
drb (2.2.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
logger (1.6.0)
minitest (5.25.0)
mysql2 (0.5.5)
pg (1.5.4)
racc (1.7.3)
rake (13.0.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.3)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.7)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.2)
ruby2ruby (2.5.1)
ruby_parser (~> 3.1)
sexp_processor (~> 4.6)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
securerandom (0.3.1)
sexp_processor (4.17.2)
sqlite3 (1.4.4)
thor (1.3.1)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activerecord (~> 7.2.0)
appraisal
byebug
hairtrigger!
mysql2 (~> 0.5)
pg (>= 0.18, < 2.0)
racc (~> 1.7.3)
rake (~> 13.0.6)
rspec (~> 3.12.0)
sqlite3 (~> 1.4.0)

BUNDLED WITH
2.5.11
7 changes: 6 additions & 1 deletion lib/hair_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def models
end

def migrator
if ActiveRecord::VERSION::STRING >= "7.1."
if Gem::Version.new("7.2.0") <= ActiveRecord.gem_version
connection = ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool
schema_migration = connection.schema_migration
migrations = ActiveRecord::MigrationContext.new(migration_path, schema_migration).migrations
ActiveRecord::Migrator.new(:up, migrations, schema_migration, ActiveRecord::InternalMetadata.new(connection))
elsif Gem::Version.new("7.1.0") <= ActiveRecord.gem_version
connection = ActiveRecord::Tasks::DatabaseTasks.migration_connection
schema_migration = connection.schema_migration
migrations = ActiveRecord::MigrationContext.new(migration_path, schema_migration).migrations
Expand Down
9 changes: 8 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ def migrate_db

def dump_schema
io = StringIO.new
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
connection = if Gem::Version.new("7.2.0") <= ActiveRecord.gem_version
ActiveRecord::Base.connection_pool
else
ActiveRecord::Base.connection
end

ActiveRecord::SchemaDumper.dump(connection, io)

io.rewind
io.read
end
Expand Down

0 comments on commit f44787c

Please sign in to comment.