FIX: backups taken by pg_dump >= 11 are nonportable (#7893)

This commit is contained in:
Michael Brown 2019-07-15 18:07:44 -04:00 committed by GitHub
parent e8ee392186
commit 08b286808a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,7 @@ module BackupRestore
attr_reader :success attr_reader :success
def self.pg_produces_portable_dump?(version) def self.pg_produces_portable_dump?(version)
version = Gem::Version.new(version) gem_version = Gem::Version.new(version)
%w{ %w{
10.3 10.3
@ -20,7 +20,9 @@ module BackupRestore
9.4.17 9.4.17
9.3.22 9.3.22
}.each do |unportable_version| }.each do |unportable_version|
return false if Gem::Dependency.new("", "~> #{unportable_version}").match?("", version) # anything pg 11 or above will produce a non-portable dump
return false if version.to_i >= 11
return false if Gem::Dependency.new("", "~> #{unportable_version}").match?("", gem_version)
end end
true true

View File

@ -12,6 +12,9 @@ describe BackupRestore::Restorer do
"10.3" => false, "10.3" => false,
"10.3.1" => false, "10.3.1" => false,
"10.4" => false, "10.4" => false,
"11" => false,
"11.4" => false,
"21" => false,
}.each do |key, value| }.each do |key, value|
expect(described_class.pg_produces_portable_dump?(key)).to eq(value) expect(described_class.pg_produces_portable_dump?(key)).to eq(value)
end end