Skip to content

Commit

Permalink
Fix db_config_with_versions arity change and backport
Browse files Browse the repository at this point in the history
  • Loading branch information
vprigent committed Nov 7, 2024
1 parent dbc2d5d commit 78716ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ Then, in the Engine's `db/data` folder, you can add data migrations and run them
Run tests for a specific version of Rails

```
bundle exec appraisal rails-6.1 rspec
bundle exec appraisal rails-7.0 rspec
bundle exec appraisal rails-7.1 rspec
Expand Down
4 changes: 3 additions & 1 deletion lib/data_migrate/database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def self.migrate_with_data

ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true

schema_mapped_versions = if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
# 7.2 removes the param for db_configs_with_versions in https://github.com/rails/rails/commit/9572fcb4a0bd5396436689a6a42613886871cd81
# 7.1 stable backported the change in https://github.com/rails/rails/commit/c53ec4b60980036b43528829d4b0b7457f759224
schema_mapped_versions = if Gem::Dependency.new("railties", ">= 7.1.4").match?("railties", Gem.loaded_specs["railties"].version, true)
ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions
else
db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
Expand Down
1 change: 1 addition & 0 deletions lib/data_migrate/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def rails_version_equal_to_or_higher_than_7_2

@equal_to_or_higher_than_7_2 = Gem::Dependency.new("railties", ">= 7.2.0.alpha").match?("railties", Gem.loaded_specs["railties"].version, true)
end

def rails_version_equal_to_or_higher_than_7_1
return @equal_to_or_higher_than_7_1 if defined?(@equal_to_or_higher_than_7_1)

Expand Down

0 comments on commit 78716ad

Please # to comment.