Module: Capistrano::Container::DB::LoadHelper
- Defined in:
- lib/db/load_helper.rb
Class Method Summary collapse
- .create_db_if_not_exists(db) ⇒ Object
- .import_on_container(container) ⇒ Object
- .import_on_local ⇒ Object
- .import_on_server ⇒ Object
Class Method Details
.create_db_if_not_exists(db) ⇒ Object
34 35 36 |
# File 'lib/db/load_helper.rb', line 34 def self.create_db_if_not_exists(db) Helper.execute_db_command_autodetect "CREATE DATABASE IF NOT EXISTS #{db};" end |
.import_on_container(container) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/db/load_helper.rb', line 16 def self.import_on_container(container) container.upload!(fetch(:db_local_dump), fetch(:db_remote_dump)) LoadHelper.create_db_if_not_exists fetch(:db_name) container.execute "mysql #{Helper::mysql_restore_args} < #{fetch(:db_remote_dump)}" end |
.import_on_local ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/db/load_helper.rb', line 8 def self.import_on_local() LoadHelper.create_db_if_not_exists fetch(:db_name) run_locally do execute "mysql #{Helper::mysql_restore_args} < #{fetch(:db_local_dump)}" end end |
.import_on_server ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/db/load_helper.rb', line 24 def self.import_on_server() on roles(:db, :container_host) do |host| upload!(fetch(:db_local_dump), fetch(:db_remote_dump)) LoadHelper.create_db_if_not_exists fetch(:db_name) execute("mysql #{Helper::mysql_restore_args} < #{fetch(:db_remote_dump)}") end end |