summaryrefslogtreecommitdiff
path: root/lib/gitlab/current_settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/current_settings.rb')
-rw-r--r--lib/gitlab/current_settings.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 48735fd197d..733d5f72f73 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -29,6 +29,8 @@ module Gitlab
return settings if settings.present?
return fake_application_settings unless connect_to_db?
+ # We can't run rake db:migrate if application settings may need a migration
+ return fake_application_settings if rake_task? && ActiveRecord::Migrator.needs_migration?
begin
db_settings = ::ApplicationSetting.current
@@ -62,10 +64,14 @@ module Gitlab
active_db_connection = ActiveRecord::Base.connection.active? rescue false
active_db_connection &&
- ActiveRecord::Base.connection.table_exists?('application_settings') &&
- !ActiveRecord::Migrator.needs_migration?
+ ActiveRecord::Base.connection.table_exists?('application_settings')
rescue ActiveRecord::NoDatabaseError
false
end
+
+ def rake_task?
+ # gitlab-rake ends up calling /opt/gitlab/embedded/bin/rake
+ $0.end_with?('rake')
+ end
end
end