Commit 1e8dbd46 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '2361-pending-migrations-break-current-settings' into 'master'

Skip loading application settings from the database when migrations are pending

Closes gitlab-ee#2361

See merge request !11842
parents 51c19616 23db8409
......@@ -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
......
......@@ -126,7 +126,7 @@ describe Projects::MergeRequestsController do
recorded = ActiveRecord::QueryRecorder.new { go(format: :json) }
expect(recorded.count).to be_within(5).of(50)
expect(recorded.count).to be_within(5).of(59)
expect(recorded.cached_count).to eq(0)
end
end
......
......@@ -113,7 +113,7 @@ describe PipelineSerializer do
it "verifies number of queries" do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(1).of(58)
expect(recorded.count).to be_within(1).of(60)
expect(recorded.cached_count).to eq(0)
end
......
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