Skip to content

Commit

Permalink
Convert port settings to String.
Browse files Browse the repository at this point in the history
  • Loading branch information
alvir committed Nov 21, 2021
1 parent d91918b commit 42acb49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/dump_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def store_dump(filename)
Hooks::Postgres.new(connection_settings)
when :mysql
Hooks::MySql.new(connection_settings)
else
raise "Unsupported type of source"
end
dumper.dump(filename_with_namespace)
end
Expand All @@ -97,6 +99,8 @@ def restore_dump(filename)
Hooks::Postgres.new(connection_settings)
when :mysql
Hooks::MySql.new(connection_settings)
else
raise "Unsupported type of source"
end
dumper.restore(filename_with_namespace)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/dump_hook/hooks/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def dump(filename)
args << "--compress"
args.concat(["--result-file", filename])
args.concat(["--ignore-table", "#{@connection_settings.database}.schema_migrations"])
args.concat ['--user', @connection_settings.username] if @connection_settings.username
args.concat(['--user', @connection_settings.username]) if @connection_settings.username
args << "--password=#{@connection_settings.password}" if @connection_settings.password
Kernel.system("mysqldump", *args)
end

def restore(filename)
args = [@connection_settings.database]
args.concat ["-e", "source #{filename}"]
args.concat ['--user', @connection_settings.username] if @connection_settings.username
args.concat(["-e", "source #{filename}"])
args.concat(['--user', @connection_settings.username]) if @connection_settings.username
args << "--password=#{@connection_settings.password}" if @connection_settings.password
Kernel.system("mysql", *args)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/dump_hook/hooks/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def dump(filename)
args.concat(['-d', @connection_settings.database])
args.concat(['-U', @connection_settings.username]) if @connection_settings.username
args.concat(['-h', @connection_settings.host]) if @connection_settings.host
args.concat(['-p', @connection_settings.port]) if @connection_settings.port
args.concat(['-p', @connection_settings.port.to_s]) if @connection_settings.port
Kernel.system("pg_dump", *args)
end

def restore(filename)
args = ['-d', @connection_settings.database]
args.concat(['-U', @connection_settings.username]) if @connection_settings.username
args.concat(['-h', @connection_settings.host]) if @connection_settings.host
args.concat(['-p', @connection_settings.port]) if @connection_settings.port
args.concat(['-p', @connection_settings.port.to_s]) if @connection_settings.port
args << filename
Kernel.system("pg_restore", *args)
end
Expand Down

0 comments on commit 42acb49

Please sign in to comment.