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.
This commit is contained in:
Daniel Uber 2021-04-15 10:50:45 -05:00 committed by GitHub
parent f45213e5c9
commit a14adaa689
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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