Skip to content

Commit 8dd4ee1

Browse files
Merge pull request #48 from zendesk/edytaroz/rails_main_testing
Rails main testing
2 parents 98c19d2 + 99cb17e commit 8dd4ee1

File tree

10 files changed

+57
-14
lines changed

10 files changed

+57
-14
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test against Rails main
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Run every day at 00:00 UTC
6+
workflow_dispatch:
7+
push:
8+
9+
jobs:
10+
specs:
11+
name: Ruby${{ matrix.ruby }} rails_main test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
ruby:
17+
- '3.3'
18+
env:
19+
BUNDLE_GEMFILE: gemfiles/rails_main.gemfile
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
- run: bundle exec rake test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ pkg
1919
mkmf.log
2020
.bundle/config
2121
.bundle/environment.rb
22+
/gemfiles/rails_main.gemfile.lock

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
migration_tools (1.9.0)
5-
activerecord (>= 6.0.0, < 7.2)
4+
migration_tools (1.10.0)
5+
activerecord (>= 6.0.0)
66

77
GEM
88
remote: https://rubygems.org/

gemfiles/rails6.0.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.9.0)
5-
activerecord (>= 6.0.0, < 7.2)
4+
migration_tools (1.10.0)
5+
activerecord (>= 6.0.0)
66

77
GEM
88
remote: https://rubygems.org/

gemfiles/rails6.1.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.9.0)
5-
activerecord (>= 6.0.0, < 7.2)
4+
migration_tools (1.10.0)
5+
activerecord (>= 6.0.0)
66

77
GEM
88
remote: https://rubygems.org/

gemfiles/rails7.0.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.9.0)
5-
activerecord (>= 6.0.0, < 7.2)
4+
migration_tools (1.10.0)
5+
activerecord (>= 6.0.0)
66

77
GEM
88
remote: https://rubygems.org/

gemfiles/rails7.1.gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
migration_tools (1.9.0)
5-
activerecord (>= 6.0.0, < 7.2)
4+
migration_tools (1.10.0)
5+
activerecord (>= 6.0.0)
66

77
GEM
88
remote: https://rubygems.org/

gemfiles/rails_main.gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source "https://rubygems.org"
2+
3+
gem "activerecord", github: "rails/rails", branch: "main"
4+
gem "sqlite3", "~> 1.4"
5+
6+
gemspec path: ".."

lib/migration_tools/tasks.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ def migrations_paths
2828
end
2929

3030
def migrator(target_version = nil)
31-
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
31+
if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
3232
migrate_up(ActiveRecord::MigrationContext.new(
3333
migrations_paths,
3434
ActiveRecord::Base.connection.schema_migration
3535
).migrations, target_version)
36+
elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
37+
migrate_up(ActiveRecord::MigrationContext.new(
38+
migrations_paths,
39+
ActiveRecord::Base.connection_pool.schema_migration
40+
).migrations, target_version)
3641
else
3742
migrate_up(ActiveRecord::MigrationContext.new(
3843
migrations_paths,
@@ -42,11 +47,16 @@ def migrator(target_version = nil)
4247
end
4348

4449
def migrate_up(migrations, target_version)
45-
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
50+
if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
4651
ActiveRecord::Migrator.new(:up, migrations,
4752
ActiveRecord::Base.connection.schema_migration,
4853
ActiveRecord::Base.connection.internal_metadata,
4954
target_version)
55+
elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
56+
ActiveRecord::Migrator.new(:up, migrations,
57+
ActiveRecord::Base.connection_pool.schema_migration,
58+
ActiveRecord::Base.connection_pool.internal_metadata,
59+
target_version)
5060
else
5161
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
5262
end

migration_tools.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Gem::Specification.new "migration_tools", "1.9.0" do |s|
1+
Gem::Specification.new "migration_tools", "1.10.0" do |s|
22
s.description = "Rake tasks for Rails that add groups to migrations"
33
s.summary = "Encourage migrations that do not require downtime"
44
s.homepage = "https://github.com/zendesk/migration_tools"
@@ -9,7 +9,7 @@ Gem::Specification.new "migration_tools", "1.9.0" do |s|
99

1010
s.required_ruby_version = ">= 2.7.0"
1111

12-
s.add_runtime_dependency "activerecord", ">= 6.0.0", "< 7.2"
12+
s.add_runtime_dependency "activerecord", ">= 6.0.0"
1313

1414
s.add_development_dependency "rake"
1515
s.add_development_dependency "bump"

0 commit comments

Comments
 (0)