diff --git a/app/controllers/health_checks_controller.rb b/app/controllers/health_checks_controller.rb index 13823eadb06942d4e510002871063055d01cc310..5283f33845cc79c18da26232e3508bc0be91b596 100644 --- a/app/controllers/health_checks_controller.rb +++ b/app/controllers/health_checks_controller.rb @@ -37,10 +37,7 @@ class HealthChecksController < ApplicationController private def check_database - ActiveRecord::Base.establish_connection # Establishes connection - ActiveRecord::Base.connection # Calls connection object - - raise 'Unable to connect to Database' unless ActiveRecord::Base.connected? + raise 'Unable to connect to Database' unless ActiveRecord::Base.connection.active? raise 'Unable to connect to Database - pending migrations' unless ActiveRecord::Migration.check_pending!.nil? rescue StandardError => e raise "Unable to connect to Database - #{e}" diff --git a/lib/tasks/configuration.rake b/lib/tasks/configuration.rake index 83fab74da8bd1f467437f589069fecf31cb004d5..09af5a61121da492efe247787e3c8284404c2f0b 100644 --- a/lib/tasks/configuration.rake +++ b/lib/tasks/configuration.rake @@ -32,9 +32,7 @@ namespace :configuration do info 'Checking connection to Postgres Database:' begin - ActiveRecord::Base.establish_connection # Establishes connection - ActiveRecord::Base.connection # Calls connection object - failed('Unable to connect to Database') unless ActiveRecord::Base.connected? + failed('Unable to connect to Database') unless ActiveRecord::Base.connection.active? rescue StandardError => e failed("Unable to connect to Database - #{e}") end