lib/dbcp/databases/mysql_database.rb in dbcp-0.0.1 vs lib/dbcp/databases/mysql_database.rb in dbcp-0.1.0
- old
+ new
@@ -1,21 +1,25 @@
module Dbcp
class MysqlDatabase < Database
def export_command(snapshot_file)
- %W[mysqldump #{socket_or_host} --user=#{username} --password=#{password} --add-drop-table --extended-insert --result-file=#{snapshot_file.path} #{database}].shelljoin
+ %W[mysqldump #{build_socket_or_host} #{build_port} --user=#{username} --password=#{password} --add-drop-table --extended-insert --result-file=#{snapshot_file.path} #{database}].reject(&:empty?).shelljoin
end
def import_command(snapshot_file)
- %W[mysql #{socket_or_host} --user=#{username} --password=#{password} #{database}].shelljoin + ' < ' + snapshot_file.path.shellescape
+ %W[mysql #{build_socket_or_host} #{build_port} --user=#{username} --password=#{password} #{database}].reject(&:empty?).shelljoin + ' < ' + snapshot_file.path.shellescape
end
private
- def socket_or_host
+ def build_socket_or_host
if socket
"--socket=#{socket}"
else
"--host=#{host}"
end
+ end
+
+ def build_port
+ "--port=#{port}" if host && port
end
end
end