summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-15 12:50:31 -0700
committerStan Hu <stanhu@gmail.com>2018-03-15 12:51:39 -0700
commit4acbc9410d2d3f5624ebf9cf8850b189524d321d (patch)
tree476bdf735bd27b7cc0ff0c837851e257d0c420e7 /lib
parentff292d40a23e3df9b08f7b4dc715f1e35bf34de1 (diff)
downloadgitlab-ce-4acbc9410d2d3f5624ebf9cf8850b189524d321d.tar.gz
Cache column_exists? for application settingssh-cache-column-exists
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')
-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