mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
backup restorer: tidy pg_dump schema portability logic, add test
This commit is contained in:
committed by
Guo Xiang Tan
parent
463d6a057c
commit
63a1e9b60a
@@ -8,6 +8,22 @@ module BackupRestore
|
||||
class Restorer
|
||||
attr_reader :success
|
||||
|
||||
def self.pg_produces_portable_dump?(version)
|
||||
version = Gem::Version.new(version)
|
||||
|
||||
%w{
|
||||
10.3
|
||||
9.6.8
|
||||
9.5.12
|
||||
9.4.17
|
||||
9.3.22
|
||||
}.each do |unportable_version|
|
||||
return false if Gem::Dependency.new("", "~> #{unportable_version}").match?("", version)
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def initialize(user_id, opts = {})
|
||||
@user_id = user_id
|
||||
@client_id = opts[:client_id]
|
||||
@@ -266,20 +282,7 @@ module BackupRestore
|
||||
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
|
||||
self.class.pg_produces_portable_dump?(get_dumped_by_version)
|
||||
end
|
||||
|
||||
def restore_dump_command
|
||||
|
Reference in New Issue
Block a user