Sha256: e8d1fffa80c150589efd7c0e2d3535c99acbb33888edbb2cd82a5cbb0c69f8a0
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
module Capistrano module Container module DB module Helper def self.mysql_dump_args command = mysql_auth_args command+= " #{fetch(:db_additional_dump_args).join(' ')} " command+= " #{fetch(:db_name)}" unless fetch(:db_name).empty? command end def self.mysql_restore_args command = mysql_auth_args command+= " #{fetch(:db_additional_restore_args).join(' ')} " command+= " #{fetch(:db_name)}" unless fetch(:db_name).empty? command end def self.mysql_auth_args command = " -u #{fetch(:db_user)}" command+= " -p#{fetch(:db_pass)}" unless fetch(:db_pass).empty? command+= " #{fetch(:db_additional_auth_args).join(' ')} " command end def self.append_stage_to_filename(file_name, stage = 'local') splitted = file_name.split('.') extension = splitted.pop splitted.push stage, extension splitted.join('.') end def self.duplicate_local_dump_to_staged_dump() staged_file = append_stage_to_filename(fetch(:db_local_dump), fetch(:stage)) FileUtils.cp(fetch(:db_local_dump), staged_file) end def self.local_stage? fetch(:local_stage_name).to_sym == fetch(:stage).to_sym end def self.execute_db_command_autodetect(cmd) cmd = "mysql #{Helper::mysql_auth_args} -e \"#{cmd}\"" if fetch(:db_is_container) db_container = container_by_name fetch(:db_container_name) on_container db_container do |container| container.execute cmd end else execute_local_or_remote cmd end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
capistrano-container-db-1.0.0 | lib/db/helper.rb |
capistrano-container-db-0.0.6 | lib/db/helper.rb |