summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-06-01 10:17:56 +0100
committerNick Thomas <nick@gitlab.com>2017-06-02 16:02:08 +0100
commit23db8409aafc6cdbae165056ec037e31096a8a66 (patch)
treeec7f4d21b7bfb8a1be6e116e9b5329df31c31bf3 /lib
parentdab266219441144a74b86fa27f4e0528810482d1 (diff)
downloadgitlab-ce-23db8409aafc6cdbae165056ec037e31096a8a66.tar.gz
Skip loading application settings from the database when migrations are pending
Various Rails initializers (metrics, sentry, etc) are run before migrations, which can lead to a mismatch between app/models/application_settings.rb and schema.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/current_settings.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 82576d197fe..9e14b35b0f8 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -19,7 +19,7 @@ module Gitlab
settings = ::ApplicationSetting.last
end
- settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
+ settings ||= ::ApplicationSetting.create_from_defaults
end
settings || in_memory_application_settings
@@ -46,7 +46,8 @@ module Gitlab
active_db_connection = ActiveRecord::Base.connection.active? rescue false
active_db_connection &&
- ActiveRecord::Base.connection.table_exists?('application_settings')
+ ActiveRecord::Base.connection.table_exists?('application_settings') &&
+ !ActiveRecord::Migrator.needs_migration?
rescue ActiveRecord::NoDatabaseError
false
end