mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-24 20:16:08 +10:00
Use ActiveRecord::Base.connection.active? and rescue any exception in connect_to_db?
This ensures that rake tasks that don't need a DB connection can be run without one.
This commit is contained in:
@@ -41,8 +41,11 @@ module Gitlab
|
||||
private
|
||||
|
||||
def connect_to_db?
|
||||
# When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
|
||||
active_db_connection = ActiveRecord::Base.connection.active? rescue false
|
||||
|
||||
ENV['USE_DB'] != 'false' &&
|
||||
ActiveRecord::Base.connection_pool.active_connection? &&
|
||||
active_db_connection &&
|
||||
ActiveRecord::Base.connection.table_exists?('application_settings')
|
||||
|
||||
rescue ActiveRecord::NoDatabaseError
|
||||
|
||||
Reference in New Issue
Block a user