only clear caches if we are actually connected to the database

Conflicts:
	activerecord/lib/active_record/railtie.rb

  https://github.com/rails/rails/commit/85cc7122bab1cfec661fdfe3bf4738d9fba55399