Skip to content

Commit

Permalink
Add support for older rails versions (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
ka8725 committed Jul 24, 2024
1 parent be4e602 commit 064c046
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PATH
remote: .
specs:
actual_db_schema (0.7.6)
activerecord (>= 6.0.0)
activesupport (>= 6.0.0)
activerecord
activesupport
csv

GEM
Expand Down
4 changes: 2 additions & 2 deletions actual_db_schema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

# Uncomment to register a new dependency of your gem
spec.add_runtime_dependency "activerecord", ">= 6.0.0"
spec.add_runtime_dependency "activesupport", ">= 6.0.0"
spec.add_runtime_dependency "activerecord"
spec.add_runtime_dependency "activesupport"
spec.add_runtime_dependency "csv"

spec.add_development_dependency "appraisal"
Expand Down
7 changes: 6 additions & 1 deletion lib/actual_db_schema/migration_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def establish_connection(db_config)
end

def configs
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
# Rails < 6.0 has a Hash in configurations
if ActiveRecord::Base.configurations.is_a?(Hash)
[ActiveRecord::Base.configurations[ActiveRecord::Tasks::DatabaseTasks.env]]
else
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
end
end

def context
Expand Down

0 comments on commit 064c046

Please sign in to comment.