Sha256: 01858cf872e3a8f0999f30704b696448a79a1dabdd4fbb1112fd14ef8a23a49a

Contents?: true

Size: 743 Bytes

Versions: 3

Compression:

Stored size: 743 Bytes

Contents

module Dbcp
  class MysqlDatabase < Database
    def export_command(snapshot_file)
      %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 #{build_socket_or_host} #{build_port} --user=#{username} --password=#{password} #{database}].reject(&:empty?).shelljoin + ' < ' + snapshot_file.path.shellescape
    end

    private

    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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dbcp-0.2.1 lib/dbcp/databases/mysql_database.rb
dbcp-0.2.0 lib/dbcp/databases/mysql_database.rb
dbcp-0.1.0 lib/dbcp/databases/mysql_database.rb