From a14adaa68970d6521ea4b68bc0835739dab84ce5 Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Thu, 15 Apr 2021 10:50:45 -0500 Subject: [PATCH] When there is no connection, answer false (#13417) When building containers, when there is no postgresql instance, this check to AR::Base.connection is raising an error. We'd like to be able to continue running `rake assets:precompile` without needing a live db to check the schema for a table. Handle connection errors as though they were a table missing. --- app/lib/database.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/database.rb b/app/lib/database.rb index b149e8b0b..6298ee673 100644 --- a/app/lib/database.rb +++ b/app/lib/database.rb @@ -7,7 +7,7 @@ module Database # @param table [String] the name of the table to check for def self.table_exists?(table) ActiveRecord::Base.connection.table_exists?(table) - rescue ActiveRecord::NoDatabaseError + rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished false end end