diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-06-27 10:08:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 10:08:08 -0400 |
commit | 40246125b99ed1f7d7ea869980523e50a0ec9a96 (patch) | |
tree | 4aed0818ec9c3c39c945bf39b71a3ce988adf9fe /activerecord/lib/active_record/tasks/database_tasks.rb | |
parent | 1518ce3dc8dc092a32cf1020ff7c67f2337b3993 (diff) | |
parent | df6b0de7d9522c46c140c556ee61e09df14ef97a (diff) | |
download | rails-40246125b99ed1f7d7ea869980523e50a0ec9a96.tar.gz rails-40246125b99ed1f7d7ea869980523e50a0ec9a96.tar.bz2 rails-40246125b99ed1f7d7ea869980523e50a0ec9a96.zip |
Merge pull request #36560 from eileencodes/warn-if-database-yml-cant-be-read
Warn if we can't read the yaml to create database tasks
Diffstat (limited to 'activerecord/lib/active_record/tasks/database_tasks.rb')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index aecc9350e8..a78bebf764 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -141,10 +141,19 @@ module ActiveRecord end end - def for_each + def setup_initial_database_yaml return {} unless defined?(Rails) - databases = Rails.application.config.load_database_yaml + begin + Rails.application.config.load_database_yaml + rescue + $stderr.puts "Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB." + + {} + end + end + + def for_each(databases) database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(env_name: Rails.env) # if this is a single database application we don't want tasks for each primary database |