Class: Handy::Db2db

Inherits:
Object
  • Object
show all
Defined in:
lib/handy/db2db.rb

Class Method Summary collapse

Class Method Details

.run(from_env, to_env, file) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/handy/db2db.rb', line 3

def self.run(from_env, to_env, file)
  from_params = "-Q --add-drop-table -O add-locks=FALSE -O lock-tables=FALSE"
  from_util = Util.retrieve_db_info(from_env)
  cmd = from_util.mysqldump_command
  cmd << " #{from_params} #{from_util.database} > #{file} "
  Util.execute_cmd(cmd)

  to_util = Util.retrieve_db_info(to_env)
  cmd = to_util.mysql_command
  cmd << " < #{file}"
  Util.execute_cmd(cmd)

  Util.pretty_msg "#{to_env} database has been restored with #{from_env} database"
end