Module: Capistrano::Container::DB::Helper
- Defined in:
- lib/db/helper.rb
Class Method Summary collapse
- .append_stage_to_filename(file_name, stage = 'local') ⇒ Object
- .duplicate_local_dump_to_staged_dump ⇒ Object
- .execute_db_command_autodetect(cmd) ⇒ Object
- .local_stage? ⇒ Boolean
- .mysql_auth_args ⇒ Object
- .mysql_dump_args ⇒ Object
- .mysql_restore_args ⇒ Object
Class Method Details
.append_stage_to_filename(file_name, stage = 'local') ⇒ Object
26 27 28 29 30 31 |
# 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 ⇒ Object
33 34 35 36 37 |
# 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) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# 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? ⇒ Boolean
39 40 41 |
# 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 ⇒ Object
19 20 21 22 23 24 |
# 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 ⇒ Object
5 6 7 8 9 10 |
# 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 ⇒ Object
12 13 14 15 16 17 |
# 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 |