Skip to content

Commit

Permalink
Drop Support for rails 6.1 and 7.0 as for ruby 3.0 and modify code to…
Browse files Browse the repository at this point in the history
… match rails 7.1 implementation
  • Loading branch information
Vakmeth committed Jan 23, 2025
1 parent 44f688a commit d466723
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 141 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1", "3.2"]
ruby-version: ["3.1", "3.2"]
gemfile:
- Gemfile
- test/ci/rails61.gemfile
- test/ci/rails70.gemfile
- test/ci/rails71.gemfile
exclude:
# Exclude Ruby 3.0 since it isn't supported with rails 7.2
- ruby-version: "3.1"
gemfile: Gemfile

env:
ROOT_BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test/ci/*.gemfile.lock
.rvmrc
.ruby-version
.byebug_history
.idea
169 changes: 84 additions & 85 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,103 +3,101 @@ PATH
specs:
wagons (0.8.0)
bundler (>= 2.0)
concurrent-ruby (< 1.3.5)
rails (>= 6.1)
seed-fu-ndo (>= 0.0.3)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
actioncable (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.3.4)
actionpack (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activesupport (= 7.1.3.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
actionmailbox (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
actionmailer (7.2.0)
actionpack (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activesupport (= 7.2.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.3.4)
actionview (= 7.1.3.4)
activesupport (= 7.1.3.4)
actionpack (7.2.0)
actionview (= 7.2.0)
activesupport (= 7.2.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.3.4)
actionpack (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
useragent (~> 0.16)
actiontext (7.2.0)
actionpack (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.3.4)
activesupport (= 7.1.3.4)
actionview (7.2.0)
activesupport (= 7.2.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.3.4)
activesupport (= 7.1.3.4)
activejob (7.2.0)
activesupport (= 7.2.0)
globalid (>= 0.3.6)
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)
activemodel (7.2.0)
activesupport (= 7.2.0)
activerecord (7.2.0)
activemodel (= 7.2.0)
activesupport (= 7.2.0)
timeout (>= 0.4.0)
activestorage (7.1.3.4)
actionpack (= 7.1.3.4)
activejob (= 7.1.3.4)
activerecord (= 7.1.3.4)
activesupport (= 7.1.3.4)
activestorage (7.2.0)
actionpack (= 7.2.0)
activejob (= 7.2.0)
activerecord (= 7.2.0)
activesupport (= 7.2.0)
marcel (~> 1.0)
activesupport (7.1.3.4)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
base64 (0.2.0)
bigdecimal (3.1.8)
builder (3.3.0)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
date (3.4.1)
drb (2.2.1)
erubi (1.13.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.14.0)
io-console (0.8.0)
irb (1.14.3)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
logger (1.6.5)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -114,8 +112,7 @@ GEM
minitest (5.24.1)
mocha (2.4.0)
ruby2_keywords (>= 0.0.5)
mutex_m (0.2.0)
net-imap (0.4.14)
net-imap (0.5.5)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -124,36 +121,36 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nio4r (2.7.4)
nokogiri (1.16.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
open4 (1.3.4)
psych (5.1.2)
psych (5.2.2)
date
stringio
racc (1.8.0)
rack (3.1.6)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rackup (2.2.1)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.3.4)
actioncable (= 7.1.3.4)
actionmailbox (= 7.1.3.4)
actionmailer (= 7.1.3.4)
actionpack (= 7.1.3.4)
actiontext (= 7.1.3.4)
actionview (= 7.1.3.4)
activejob (= 7.1.3.4)
activemodel (= 7.1.3.4)
activerecord (= 7.1.3.4)
activestorage (= 7.1.3.4)
activesupport (= 7.1.3.4)
rails (7.2.0)
actioncable (= 7.2.0)
actionmailbox (= 7.2.0)
actionmailer (= 7.2.0)
actionpack (= 7.2.0)
actiontext (= 7.2.0)
actionview (= 7.2.0)
activejob (= 7.2.0)
activemodel (= 7.2.0)
activerecord (= 7.2.0)
activestorage (= 7.2.0)
activesupport (= 7.2.0)
bundler (>= 1.15.0)
railties (= 7.1.3.4)
railties (= 7.2.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -165,37 +162,39 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3.4)
actionpack (= 7.1.3.4)
activesupport (= 7.1.3.4)
irb
railties (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.2.1)
rdoc (6.7.0)
rdoc (6.10.0)
psych (>= 4.0.0)
reline (0.5.9)
reline (0.6.0)
io-console (~> 0.5)
ruby2_keywords (0.0.5)
securerandom (0.4.1)
seed-fu (2.3.9)
activerecord (>= 3.1)
activesupport (>= 3.1)
seed-fu-ndo (0.0.3)
seed-fu (>= 2.2.0)
sqlite3 (1.7.3)
sqlite3 (2.1.0)
mini_portile2 (~> 2.8.0)
stringio (3.1.1)
thor (1.3.1)
stringio (3.1.2)
thor (1.3.2)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.8.2)
websocket-driver (0.7.6)
useragent (0.16.11)
websocket-driver (0.7.7)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.16)
zeitwerk (2.7.1)

PLATFORMS
ruby
Expand All @@ -205,7 +204,7 @@ DEPENDENCIES
net-smtp
open4
rails-controller-testing
sqlite3 (~> 1.4)
sqlite3 (<= 2.1)
wagons!

BUNDLED WITH
Expand Down
5 changes: 3 additions & 2 deletions lib/tasks/wagons.rake
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ eval(File.read(wagonfile)) if File.exist?(wagonfile)"
pending_migrations = ActiveRecord::Migrator.new(
:up,
context.migrations,
ActiveRecord::SchemaMigration
ActiveRecord::SchemaMigration,
InternalMetadata.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool)
).pending_migrations

if pending_migrations.any?
Expand Down Expand Up @@ -186,7 +187,7 @@ namespace :db do
Rake::Task[:'db:_dump'].clear_actions

task :_dump do
context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths, ActiveRecord::SchemaMigration)
context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths)
migrated = Set.new(context.get_all_versions)
if migrated.size > context.migrations.size
puts "The database schema will not be dumped when there are loaded wagon migrations."
Expand Down
32 changes: 6 additions & 26 deletions lib/wagons/extensions/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ def maintain_test_schema_with_wagons!
suppress_messages { load_wagon_schema! }
end
end

alias maintain_test_schema_without_wagons! maintain_test_schema!
alias maintain_test_schema! maintain_test_schema_with_wagons!

private

def load_wagon_schema!
if rails_version_smaller_than('7.1.0')
Base.clear_all_connections!
else
Base.connection_handler.clear_all_connections!
end

Base.connection_handler.clear_all_connections!
# Contrary to the original rails approach (#load_schema_if_pending!),
# purge the database first to get rid of all wagon tables.
config = Base.configurations.configs_for(env_name: 'test').first
Expand All @@ -38,11 +34,7 @@ def load_wagon_schema!

def load_app_schema(config)
Tasks::DatabaseTasks.load_schema(config)
if rails_version_smaller_than('7.1.0')
check_pending!
else
check_all_pending!
end
check_all_pending!
end

def app_needs_migration?
Expand All @@ -63,27 +55,15 @@ def migration_versions_in_db
end

def schema_migration_table_exists?
if rails_version_smaller_than('7.1.0')
Base.connection.table_exists?(SchemaMigration.table_name)
else
SchemaMigration.new(Base.connection).table_exists?
end
ActiveRecord::Base.connection.data_source_exists?(ActiveRecord::Base.schema_migrations_table_name)
end

def migration_context
if rails_version_smaller_than('7.1.0')
MigrationContext.new(Migrator.migrations_paths, SchemaMigration)
else
MigrationContext.new(Migrator.migrations_paths)
end
MigrationContext.new(Migrator.migrations_paths)
end

def maintain_test_schema?
if rails_version_smaller_than('7.0.0')
ActiveRecord::Base.maintain_test_schema
else
ActiveRecord.maintain_test_schema
end
ActiveRecord.maintain_test_schema
end

def rails_version_smaller_than(version)
Expand Down
11 changes: 0 additions & 11 deletions test/ci/rails61.gemfile

This file was deleted.

Loading

0 comments on commit d466723

Please sign in to comment.