From 0d73af3824418783201f36f60e6314c04d15af3d Mon Sep 17 00:00:00 2001 From: Bruno Costanzo Date: Tue, 20 Aug 2024 21:49:02 +0200 Subject: [PATCH 1/2] Change db_configs_with_versions call when Rails is higher than 7.1 --- lib/data_migrate/database_tasks.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 3f5a914..e4fad86 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -179,9 +179,14 @@ def self.migrate_with_data ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env) + schema_mapped_versions = if rails_version_equal_to_or_higher_than_7_1 + ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions + else + db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env) + + ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs) + end - schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs) data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs| From 3adf3c8439c9d39ba85baedfc66a970e8f173511 Mon Sep 17 00:00:00 2001 From: "Igor S. Morozov" Date: Tue, 20 Aug 2024 22:29:44 +0200 Subject: [PATCH 2/2] Update lib/data_migrate/database_tasks.rb --- lib/data_migrate/database_tasks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index e4fad86..90f9a27 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -179,7 +179,7 @@ def self.migrate_with_data ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - schema_mapped_versions = if rails_version_equal_to_or_higher_than_7_1 + schema_mapped_versions = if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions else db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)