Skip to content

Commit

Permalink
Merge pull request #46 from zendesk/bquorning/drop-oldies
Browse files Browse the repository at this point in the history
Drop support for old Ruby and Rails versions
  • Loading branch information
bquorning authored Nov 29, 2023
2 parents a7c99fc + 6d743a2 commit 02b9a49
Show file tree
Hide file tree
Showing 18 changed files with 14 additions and 269 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ jobs:
- rails6.1
- rails7.0
- rails7.1
include:
- {ruby-version: '2.6', gemfile: rails4.2}
- {ruby-version: '2.6', gemfile: rails5.0}
- {ruby-version: '2.6', gemfile: rails5.1}
- {ruby-version: '2.6', gemfile: rails5.2}
- {ruby-version: '2.7', gemfile: rails5.2}
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
migration_tools (1.9.0)
activerecord (>= 4.2.0, < 7.2)
activerecord (>= 6.0.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 0 additions & 6 deletions gemfiles/rails4.2.gemfile

This file was deleted.

54 changes: 0 additions & 54 deletions gemfiles/rails4.2.gemfile.lock

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/rails5.0.gemfile

This file was deleted.

52 changes: 0 additions & 52 deletions gemfiles/rails5.0.gemfile.lock

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/rails5.1.gemfile

This file was deleted.

54 changes: 0 additions & 54 deletions gemfiles/rails5.1.gemfile.lock

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/rails5.2.gemfile

This file was deleted.

54 changes: 0 additions & 54 deletions gemfiles/rails5.2.gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails6.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
migration_tools (1.9.0)
activerecord (>= 4.2.0, < 7.2)
activerecord (>= 6.0.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails6.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
migration_tools (1.9.0)
activerecord (>= 4.2.0, < 7.2)
activerecord (>= 6.0.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails7.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
migration_tools (1.9.0)
activerecord (>= 4.2.0, < 7.2)
activerecord (>= 6.0.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails7.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
migration_tools (1.9.0)
activerecord (>= 4.2.0, < 7.2)
activerecord (>= 6.0.0, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
10 changes: 2 additions & 8 deletions lib/migration_tools/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ def migrator(target_version = nil)
migrations_paths,
ActiveRecord::Base.connection.schema_migration
).migrations, target_version)
elsif ActiveRecord::VERSION::MAJOR >= 6
else
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
ActiveRecord::SchemaMigration
).migrations, target_version)
elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2
migrate_up(ActiveRecord::MigrationContext.new(migrations_paths).migrations, target_version)
else
migrate_up(ActiveRecord::Migrator.migrations(migrations_paths), target_version)
end
end

Expand All @@ -52,10 +48,8 @@ def migrate_up(migrations, target_version)
ActiveRecord::Base.connection.internal_metadata,
target_version
)
elsif ActiveRecord::VERSION::MAJOR >= 6
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
else
ActiveRecord::Migrator.new(:up, migrations, target_version)
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
end
end

Expand Down
4 changes: 2 additions & 2 deletions migration_tools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Gem::Specification.new "migration_tools", "1.9.0" do |s|
s.files = `git ls-files lib`.split("\n")
s.license = "Apache-2.0"

s.required_ruby_version = '>= 2.6.0'
s.required_ruby_version = '>= 2.7.0'

s.add_runtime_dependency "activerecord", '>= 4.2.0', '< 7.2'
s.add_runtime_dependency "activerecord", '>= 6.0.0', '< 7.2'

s.add_development_dependency "rake"
s.add_development_dependency "bump"
Expand Down
8 changes: 2 additions & 6 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
require 'active_support/all'
require 'migration_tools'

MIGRATION_CLASS = if ActiveRecord::Migration.respond_to?(:[])
rails_version = "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}".to_f
ActiveRecord::Migration[rails_version]
else
ActiveRecord::Migration
end
rails_version = "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}".to_f
MIGRATION_CLASS = ActiveRecord::Migration[rails_version]

dir = File.expand_path('../migrations', __FILE__)
ActiveRecord::Migrator.migrations_paths.replace([dir])
Expand Down
7 changes: 3 additions & 4 deletions test/test_migration_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ def migration_proxy(m)
end
end

if ActiveRecord.gem_version >= Gem::Version.new("5.0")
require 'active_support/testing/stream'
include ActiveSupport::Testing::Stream
end
require 'active_support/testing/stream'
include ActiveSupport::Testing::Stream

it "abort_if_pending_migrations_with_group_with_migrations" do
assert_raises(SystemExit, "did not abort") do
silence_stream($stdout) do
Expand Down

0 comments on commit 02b9a49

Please sign in to comment.