Commit 64f3ddcc authored by Rémy Coutable's avatar Rémy Coutable Committed by Kirill Smelkov

Ensure rake tasks that don't need a DB connection can be run without one

( cherry picked from commit e6f3fe5d upstream )

When using ActiveRecord::Base.connection.active? without a DB
connection, we get a "PG::ConnectionBad: could not connect to server"
error because ActiveRecord::Base.connection doesn't exist. By using
ActiveRecord::Base.connected? we ensure we don't get this error if
the connection is missing, which is the all point of the
Gitlab::CurrentSettings#connect_to_db? method!
parent 78f0ba8f
...@@ -38,7 +38,7 @@ module Gitlab ...@@ -38,7 +38,7 @@ module Gitlab
true true
end end
use_db && ActiveRecord::Base.connection.active? && use_db && ActiveRecord::Base.connected? &&
!ActiveRecord::Migrator.needs_migration? && !ActiveRecord::Migrator.needs_migration? &&
ActiveRecord::Base.connection.table_exists?('application_settings') ActiveRecord::Base.connection.table_exists?('application_settings')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment