Class: GrokCLI::Docker::WordPress::ImportDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/grok_cli/docker/wordpress/import_database.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = GrokCLI::Docker::Configuration.new) ⇒ ImportDatabase

Returns a new instance of ImportDatabase.



3
4
5
# File 'lib/grok_cli/docker/wordpress/import_database.rb', line 3

def initialize(config = GrokCLI::Docker::Configuration.new)
  @config = config
end

Instance Method Details

#execute(sql_dump) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/grok_cli/docker/wordpress/import_database.rb', line 7

def execute(sql_dump)
  system <<~CMD

    docker-machine create #{@config.machine_name} --driver virtualbox

    eval "$(docker-machine env #{@config.machine_name})"

    docker-compose run --rm mysql mysql -h mysql -u#{username} -p#{password} #{database} < #{sql_dump}
  CMD
end