From 08b286808ac13dbb6501ae306ebd971269cd24c9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 15 Jul 2019 18:07:44 -0400 Subject: [PATCH] FIX: backups taken by pg_dump >= 11 are nonportable (#7893) --- lib/backup_restore/restorer.rb | 6 ++++-- spec/lib/backup_restore/restorer_spec.rb | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/backup_restore/restorer.rb b/lib/backup_restore/restorer.rb index c7ff9266d56..1e95502242e 100644 --- a/lib/backup_restore/restorer.rb +++ b/lib/backup_restore/restorer.rb @@ -11,7 +11,7 @@ module BackupRestore attr_reader :success def self.pg_produces_portable_dump?(version) - version = Gem::Version.new(version) + gem_version = Gem::Version.new(version) %w{ 10.3 @@ -20,7 +20,9 @@ module BackupRestore 9.4.17 9.3.22 }.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 true diff --git a/spec/lib/backup_restore/restorer_spec.rb b/spec/lib/backup_restore/restorer_spec.rb index 1cd1dd698eb..49f829b27e5 100644 --- a/spec/lib/backup_restore/restorer_spec.rb +++ b/spec/lib/backup_restore/restorer_spec.rb @@ -12,6 +12,9 @@ describe BackupRestore::Restorer do "10.3" => false, "10.3.1" => false, "10.4" => false, + "11" => false, + "11.4" => false, + "21" => false, }.each do |key, value| expect(described_class.pg_produces_portable_dump?(key)).to eq(value) end