Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-15 22:50:31 +0300
committerStan Hu <stanhu@gmail.com>2018-03-15 22:51:39 +0300
commit4acbc9410d2d3f5624ebf9cf8850b189524d321d (patch)
tree476bdf735bd27b7cc0ff0c837851e257d0c420e7 /lib/gitlab/database.rb
parentff292d40a23e3df9b08f7b4dc715f1e35bf34de1 (diff)
Cache column_exists? for application settings
This is most a backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4987/diffs but includes other columns that use column_exists? in a way that may cause unnecessary schema loads.
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r--lib/gitlab/database.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index e51794fef99..d4fc69cb173 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -183,6 +183,10 @@ module Gitlab
ActiveRecord::Base.connection
end
+ def self.cached_column_exists?(table_name, column_name)
+ connection.schema_cache.columns_hash(table_name).has_key?(column_name.to_s)
+ end
+
private_class_method :connection
def self.database_version