diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-14 13:12:37 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-14 13:12:37 +0000 |
commit | 17335a42aea4c9ddccbe92527752ae0e6b9b7835 (patch) | |
tree | 036eab1e7ca9a0d1533785f34263a2299ca7f2ef /lib | |
parent | c4a3587c7700eb4731502223e4683360454ed0d4 (diff) | |
parent | fa36101a7fc8679d98198942f15dd6285673594d (diff) | |
download | gitlab-ce-17335a42aea4c9ddccbe92527752ae0e6b9b7835.tar.gz |
Merge branch 'rails5-database' into 'master'
Fix table_exists? to be Rails5 compatible
Closes #45107
See merge request gitlab-org/gitlab-ce!19418
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/background_migration/prepare_untracked_uploads.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/database.rb | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb index 914a9e48a2f..522c69a0bb1 100644 --- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb +++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb @@ -54,7 +54,8 @@ module Gitlab def ensure_temporary_tracking_table_exists table_name = :untracked_files_for_uploads - unless UntrackedFile.connection.table_exists?(table_name) + + unless ActiveRecord::Base.connection.data_source_exists?(table_name) UntrackedFile.connection.create_table table_name do |t| t.string :path, limit: 600, null: false t.index :path, unique: true diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index d49d055c3f2..4ad106e7b0a 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -188,8 +188,11 @@ module Gitlab end def self.cached_table_exists?(table_name) - # Rails 5 uses data_source_exists? instead of table_exists? - connection.schema_cache.table_exists?(table_name) + if Gitlab.rails5? + connection.schema_cache.data_source_exists?(table_name) + else + connection.schema_cache.table_exists?(table_name) + end end private_class_method :connection |