Commit 93032262 authored by Stan Hu's avatar Stan Hu

Merge branch 'bw-replication-slots-supported' into 'master'

add Gitlab::Database.replication_slots_supported?

See merge request gitlab-org/gitlab-ce!15744
parents 784edd65 02d97d46
...@@ -50,6 +50,10 @@ module Gitlab ...@@ -50,6 +50,10 @@ module Gitlab
postgresql? && version.to_f >= 9.3 postgresql? && version.to_f >= 9.3
end end
def self.replication_slots_supported?
postgresql? && version.to_f >= 9.4
end
def self.nulls_last_order(field, direction = 'ASC') def self.nulls_last_order(field, direction = 'ASC')
order = "#{field} #{direction}" order = "#{field} #{direction}"
......
...@@ -73,6 +73,28 @@ describe Gitlab::Database do ...@@ -73,6 +73,28 @@ describe Gitlab::Database do
end end
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 describe '.nulls_last_order' do
context 'when using PostgreSQL' do context 'when using PostgreSQL' do
before do before do
......
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