class Martilla::Mysql

Public Instance Methods

dump(tmp_file:, gzip:) click to toggle source
# File lib/martilla/databases/mysql.rb, line 3
def dump(tmp_file:, gzip:)
  if gzip
    bash("set -o pipefail && mysqldump #{connection_arguments} | gzip -c > #{tmp_file}")
  else
    bash("mysqldump #{connection_arguments} > #{tmp_file}")
  end

  return if $?.success?
  raise Error.new("Database dump failed with code #{$?.exitstatus}")
end

Private Instance Methods

connection_arguments() click to toggle source
# File lib/martilla/databases/mysql.rb, line 16
def connection_arguments
  "-u #{user} --password=#{password} --host=#{host} -P #{port} #{db}"
end
db() click to toggle source
# File lib/martilla/databases/mysql.rb, line 36
def db
  @options['db'] || ENV['MYSQL_DATABASE'] || '--all-databases'
end
host() click to toggle source
# File lib/martilla/databases/mysql.rb, line 20
def host
  @options['host'] || ENV['MYSQL_HOST'] || 'localhost'
end
password() click to toggle source
# File lib/martilla/databases/mysql.rb, line 32
def password
  @options['password'] || ENV['MYSQL_PASSWORD']
end
port() click to toggle source
# File lib/martilla/databases/mysql.rb, line 24
def port
  @options['port'] || ENV['MYSQL_PORT'] || '3306'
end
user() click to toggle source
# File lib/martilla/databases/mysql.rb, line 28
def user
  @options['user'] || ENV['MYSQL_USER']
end