Fix version check in restorer.

This commit is contained in:
Guo Xiang Tan 2018-03-09 14:28:50 +08:00
parent 800760e353
commit 766b41d9f4
1 changed files with 18 additions and 4 deletions

View File

@ -39,11 +39,8 @@ module BackupRestore
validate_metadata
extract_dump
dumped_by_version = Gem::Version.new(get_dumped_by_version)
if dumped_by_version >= Gem::Version.new("10.3") ||
dumped_by_version >= Gem::Version.new("9.5.12")
if !can_restore_into_different_schema?
enable_readonly_mode
pause_sidekiq
@ -266,6 +263,23 @@ module BackupRestore
output.match(/version (\d+(\.\d+)?)/)[1]
end
def can_restore_into_different_schema?
dumped_by_version = Gem::Version.new(get_dumped_by_version)
return false if dumped_by_version >= Gem::Version.new("10.3")
%w{
9.6.8
9.5.12
9.4.17
9.3.22
}.each do |version|
return false if Gem::Dependency.new("", "~> #{version}").match?("", dumped_by_version)
end
true
end
def restore_dump_command
if File.extname(@dump_filename) == '.gz'
"gzip -d < #{@dump_filename} | #{sed_command} | #{psql_command} 2>&1"