Skip to content

Commit

Permalink
Merge pull request #16 from ArthurWD/development
Browse files Browse the repository at this point in the history
Don't crash when no database connection is present
  • Loading branch information
rpbaltazar authored Mar 22, 2020
2 parents 65db2c6 + 4eb1681 commit 2f11740
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/apartment/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class Railtie < Rails::Railtie
Apartment::Tenant.init
end
# rubocop:disable Lint/SuppressedException
rescue ::ActiveRecord::NoDatabaseError
rescue ::ActiveRecord::NoDatabaseError, PG::ConnectionBad
# Since `db:create` and other tasks invoke this block from Rails 5.2.0,
# we need to swallow the error to execute `db:create` properly.
Rails.logger.warn do
'Failed to initialize Apartment because a database connection could not be established.'
end
end
# rubocop:enable Lint/SuppressedException
end
Expand Down

0 comments on commit 2f11740

Please sign in to comment.