lib/capistrano/tasks/z10_remote_db_diff.rb
# Performs the actual sequence of operations required by a single db:rebuild_from_dump
# task, given the specified parameters but only LOCALLY, in the context of Capistrano.
#
# The source_basename comes from the name of the file dump.
# Note that the dump takes the name of the Environment configuration section.
#
Performs the actual sequence of operations required by a single db:rebuild_from_dump
task, given the specified parameters but only LOCALLY, in the context of Capistrano.

The source_basename comes from the name of the file dump.
Note that the dump takes the name of the Environment configuration section.
Performs the actual sequence of operations required by a single db : rebuild_from_dump task given the specified parameters but only LOCALLY in the context of Capistrano . The source_basename comes from the name of the file dump . Note that the dump takes the name of the Environment configuration section .
def local_rebuild_from_dump( db_dump_dir, source_basename, output_db, db_host, db_user, db_pwd, file_ext = '.sql.bz2' )
    puts "\r\nRebuilding..."
    puts "DB name: #{ source_basename } (dump) => #{ output_db } (DEST)"
    puts "DB user: #{ db_user }"
    file_name = File.join( db_dump_dir, "#{ source_basename }#{ file_ext }" )
    sql_file_name = File.join( 'tmp', "#{ source_basename }.sql" )
    run_locally do
      puts "\r\nUncompressing dump file '#{ file_name }' => '#{ sql_file_name }'..."
      execute :bunzip2, "-ck #{ file_name } > #{ sql_file_name }"
      puts "\r\nDropping destination DB '#{ output_db }'..."
      execute :mysql, "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --execute=\"drop database if exists #{ output_db }\""
      puts "\r\nRecreating destination DB..."
      execute :mysql, "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --execute=\"create database #{ output_db }\""
      puts "\r\nExecuting '#{ file_name }' on #{ output_db }..."
      execute :mysql, "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --database=#{ output_db } --execute=\"\\. #{ sql_file_name }\""
      puts "Deleting uncompressed file '#{ sql_file_name }'..."
      FileUtils.rm( sql_file_name )
    end
    puts "Rebuild from dump for '#{ source_basename }', done.\r\n\r\n"
  end
def local_rebuild_from_dump ( db_dump_dir , source_basename , output_db , db_host , db_user , db_pwd , file_ext = '.sql.bz2' ) puts "\r\nRebuilding..." puts "DB name: #{ source_basename } (dump) => #{ output_db } (DEST)" puts "DB user: #{ db_user }" file_name = File . join ( db_dump_dir , "#{ source_basename }#{ file_ext }" ) sql_file_name = File . join ( 'tmp' , "#{ source_basename }.sql" ) run_locally do puts "\r\nUncompressing dump file '#{ file_name }' => '#{ sql_file_name }'..." execute :bunzip2 , "-ck #{ file_name } > #{ sql_file_name }" puts "\r\nDropping destination DB '#{ output_db }'..." execute :mysql , "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --execute=\"drop database if exists #{ output_db }\"" puts "\r\nRecreating destination DB..." execute :mysql , "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --execute=\"create database #{ output_db }\"" puts "\r\nExecuting '#{ file_name }' on #{ output_db }..." execute :mysql , "--host=#{ db_host } --user=#{ db_user } --password=\"#{db_pwd}\" --database=#{ output_db } --execute=\"\\. #{ sql_file_name }\"" puts "Deleting uncompressed file '#{ sql_file_name }'..." FileUtils . rm ( sql_file_name ) end puts "Rebuild from dump for '#{ source_basename }', done.\r\n\r\n" end
Performs the actual sequence of operations required by a single db:rebuild_from_dump
task, given the specified parameters but only LOCALLY, in the context of Capistrano.
Performs the actual sequence of operations required by a single db : rebuild_from_dump task given the specified parameters but only LOCALLY in the context of Capistrano .
db_dump_dir
<not_specific>
source_basename
<not_specific>
output_db
<not_specific>
db_host
<not_specific>
db_user
<not_specific>
db_pwd
<not_specific>
file_ext
<not_specific>