Class: Wordmove::Deployer::Ssh::WpcliSqlAdapter

Inherits:
Wordmove::Deployer::SSH show all
Defined in:
lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb

Instance Attribute Summary

Attributes inherited from Wordmove::Deployer::SSH

#local_backup_path, #local_dump_path, #local_gzipped_backup_path, #local_gzipped_dump_path

Attributes inherited from Base

#environment, #logger, #options

Instance Method Summary collapse

Methods inherited from Wordmove::Deployer::SSH

#initialize

Methods inherited from Base

current_dir, deployer_for, #exclude_dir_contents, #initialize, logger, #pull_db, #pull_wordpress, #push_db, #push_wordpress, #remote_get_directory, #remote_put_directory

Constructor Details

This class inherits a constructor from Wordmove::Deployer::SSH

Instance Method Details

#adapt_local_db!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 9

def adapt_local_db!
  save_local_db(local_dump_path)
  run wpcli_search_replace(local_options, remote_options, :vhost)
  run wpcli_search_replace(local_options, remote_options, :wordpress_path)

  local_search_replace_dump_path = local_wp_content_dir.path("search_replace_dump.sql")
  local_gzipped_search_replace_dump_path = local_search_replace_dump_path + '.gz'

  save_local_db(local_search_replace_dump_path)
  run compress_command(local_search_replace_dump_path)
  import_remote_dump(local_gzipped_search_replace_dump_path)
  local_delete(local_gzipped_search_replace_dump_path)
  run mysql_import_command(local_dump_path, local_options[:database])
end

#adapt_remote_db!Object



33
34
35
36
37
38
39
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 33

def adapt_remote_db!
  download_remote_db(local_gzipped_dump_path)
  run uncompress_command(local_gzipped_dump_path)
  run mysql_import_command(local_dump_path, local_options[:database])
  run wpcli_search_replace(remote_options, local_options, :vhost)
  run wpcli_search_replace(remote_options, local_options, :wordpress_path)
end

#after_pull_cleanup!Object



41
42
43
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 41

def after_pull_cleanup!
  local_delete(local_dump_path)
end

#after_push_cleanup!Object



24
25
26
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 24

def after_push_cleanup!
  local_delete(local_dump_path)
end

#backup_local_db!Object



28
29
30
31
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 28

def backup_local_db!
  save_local_db(local_backup_path)
  run compress_command(local_backup_path)
end

#backup_remote_db!Object



5
6
7
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 5

def backup_remote_db!
  download_remote_db(local_gzipped_backup_path)
end

#wpcli_search_replace(local, remote, config_key) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb', line 45

def wpcli_search_replace(local, remote, config_key)
  return if options[:no_adapt]

  logger.task_step true, "adapt dump for #{config_key}"
  path = local_options[:wordpress_path]
  SqlAdapter::Wpcli.new(local, remote, config_key, path).command unless simulate?
end