summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-12-05 16:43:48 +0000
committerStan Hu <stanhu@gmail.com>2017-12-05 16:43:48 +0000
commit93032262fb1e1240e2618b39d3dab9c4de673d39 (patch)
treee8655dbc12e78e2f20e394564eb182b5eeead88f
parent784edd654b8ef36535d3c1773b7a43d8f3c19b23 (diff)
parent02d97d46216b60568fb248f9aeb779528abd8e9c (diff)
downloadgitlab-ce-93032262fb1e1240e2618b39d3dab9c4de673d39.tar.gz
Merge branch 'bw-replication-slots-supported' into 'master'
add Gitlab::Database.replication_slots_supported? See merge request gitlab-org/gitlab-ce!15744
-rw-r--r--lib/gitlab/database.rb4
-rw-r--r--spec/lib/gitlab/database_spec.rb22
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index cd7b4c043da..96922e1a62f 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -50,6 +50,10 @@ module Gitlab
postgresql? && version.to_f >= 9.3
end
+ def self.replication_slots_supported?
+ postgresql? && version.to_f >= 9.4
+ end
+
def self.nulls_last_order(field, direction = 'ASC')
order = "#{field} #{direction}"
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index fcddfad3f9f..a5657b81952 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -73,6 +73,28 @@ describe Gitlab::Database do
end
end
+ describe '.replication_slots_supported?' do
+ it 'returns false when using MySQL' do
+ allow(described_class).to receive(:postgresql?).and_return(false)
+
+ expect(described_class.replication_slots_supported?).to eq(false)
+ end
+
+ it 'returns false when using PostgreSQL 9.3' do
+ allow(described_class).to receive(:postgresql?).and_return(true)
+ allow(described_class).to receive(:version).and_return('9.3.1')
+
+ expect(described_class.replication_slots_supported?).to eq(false)
+ end
+
+ it 'returns true when using PostgreSQL 9.4.0 or newer' do
+ allow(described_class).to receive(:postgresql?).and_return(true)
+ allow(described_class).to receive(:version).and_return('9.4.0')
+
+ expect(described_class.replication_slots_supported?).to eq(true)
+ end
+ end
+
describe '.nulls_last_order' do
context 'when using PostgreSQL' do
before do