Actions
Refactor #24619
closedWith Rails 5.2 db:create fails when plugins present
Description
It seems that in Rails 5.2, they started to initialize rails environment even in db:create rake tasks, causing issues in couple of places.
Steps to reproduce
1. configure foreman to use non-existing database
2. add a plugin
3. run `rake db:create`
Fails with:
07:06:00 ActiveRecord::NoDatabaseError: FATAL: database "test_develop_pr_katello-0-dev" does not exist 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:688:in `rescue in connect' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:683:in `connect' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/schema_migration.rb:22:in `table_exists?' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/schema_migration.rb:26:in `create_table' 07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1187:in `initialize' 07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:325:in `new' 07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:325:in `pending_migrations' 07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:269:in `permission'
Actions