module Capistrano::Container::DB::Helper
Public Class Methods
append_stage_to_filename(file_name, stage = 'local')
click to toggle source
# File lib/db/helper.rb, line 26 def self.append_stage_to_filename(file_name, stage = 'local') splitted = file_name.split('.') extension = splitted.pop splitted.push stage, extension splitted.join('.') end
duplicate_local_dump_to_staged_dump()
click to toggle source
# File lib/db/helper.rb, line 33 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
execute_db_command_autodetect(cmd)
click to toggle source
# File lib/db/helper.rb, line 43 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
local_stage?()
click to toggle source
# File lib/db/helper.rb, line 39 def self.local_stage? fetch(:local_stage_name).to_sym == fetch(:stage).to_sym end
mysql_auth_args()
click to toggle source
# File lib/db/helper.rb, line 19 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
mysql_dump_args()
click to toggle source
# File lib/db/helper.rb, line 5 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
mysql_restore_args()
click to toggle source
# File lib/db/helper.rb, line 12 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