Skip to content

Commit

Permalink
Merge branch 'use_db_for_application_settings' into 'master'
Browse files Browse the repository at this point in the history
Check if database connection exists when loading application settings

!1217 broke omnibus-gitlab nightly builds. In omnibus-gitlab we precompile assets without a running database.

See merge request !1230
  • Loading branch information
maxlazio committed Sep 1, 2015
2 parents afb2e6f + 3a8773f commit 308c642
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Expand Up @@ -30,6 +30,7 @@ v 8.0.0 (unreleased)
- Fixed login failure when extern_uid changes (Joel Koglin)
- Don't notify users without access to the project when they are (accidentally) mentioned in a note.
- Retrieving oauth token with LDAP credentials
- Load Application settings from running database unless env var USE_DB=false

v 7.14.1
- Improve abuse reports management from admin area
Expand Down Expand Up @@ -114,7 +115,7 @@ v 7.13.4
v 7.13.3
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
- Allow users to send abuse reports
- Remove satellites
- Remove satellites
- Link username to profile on Group Members page (Tom Webster)

v 7.13.2
Expand Down
14 changes: 13 additions & 1 deletion lib/gitlab/current_settings.rb
Expand Up @@ -4,7 +4,7 @@ def current_application_settings
key = :current_application_settings

RequestStore.store[key] ||= begin
if ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings')
if connect_to_db?
ApplicationSetting.current || ApplicationSetting.create_from_defaults
else
fake_application_settings
Expand All @@ -26,5 +26,17 @@ def fake_application_settings
import_sources: Settings.gitlab['import_sources']
)
end

private

def connect_to_db?
use_db = if ENV['USE_DB'] == "false"
false
else
true
end

use_db && ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings')
end
end
end

0 comments on commit 308c642

Please sign in to comment.