Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/rails_main_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test against Rails main

on:
schedule:
- cron: "0 0 * * *" # Run every day at 00:00 UTC
workflow_dispatch:
push:

jobs:
specs:
name: Ruby${{ matrix.ruby }} rails_main test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- '3.3'
env:
BUNDLE_GEMFILE: gemfiles/rails_main.gemfile
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pkg
mkmf.log
.bundle/config
.bundle/environment.rb
/gemfiles/rails_main.gemfile.lock
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
migration_tools (1.9.0)
activerecord (>= 6.0.0, < 7.2)
migration_tools (1.10.0)
activerecord (>= 6.0.0)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails6.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: ..
specs:
migration_tools (1.9.0)
activerecord (>= 6.0.0, < 7.2)
migration_tools (1.10.0)
activerecord (>= 6.0.0)

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

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

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

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/rails_main.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem "activerecord", github: "rails/rails", branch: "main"
gem "sqlite3", "~> 1.4"

gemspec path: ".."
14 changes: 12 additions & 2 deletions lib/migration_tools/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ def migrations_paths
end

def migrator(target_version = nil)
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
ActiveRecord::Base.connection.schema_migration
).migrations, target_version)
elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
ActiveRecord::Base.connection_pool.schema_migration
).migrations, target_version)
else
migrate_up(ActiveRecord::MigrationContext.new(
migrations_paths,
Expand All @@ -42,11 +47,16 @@ def migrator(target_version = nil)
end

def migrate_up(migrations, target_version)
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
ActiveRecord::Migrator.new(:up, migrations,
ActiveRecord::Base.connection.schema_migration,
ActiveRecord::Base.connection.internal_metadata,
target_version)
elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
ActiveRecord::Migrator.new(:up, migrations,
ActiveRecord::Base.connection_pool.schema_migration,
ActiveRecord::Base.connection_pool.internal_metadata,
target_version)
else
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
end
Expand Down
4 changes: 2 additions & 2 deletions migration_tools.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Gem::Specification.new "migration_tools", "1.9.0" do |s|
Gem::Specification.new "migration_tools", "1.10.0" do |s|
s.description = "Rake tasks for Rails that add groups to migrations"
s.summary = "Encourage migrations that do not require downtime"
s.homepage = "https://github.com/zendesk/migration_tools"
Expand All @@ -9,7 +9,7 @@ Gem::Specification.new "migration_tools", "1.9.0" do |s|

s.required_ruby_version = ">= 2.7.0"

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

s.add_development_dependency "rake"
s.add_development_dependency "bump"
Expand Down