Module: LoadHelper

Defined in:
lib/db/load_helper.rb

Class Method Summary collapse

Class Method Details

.create_db_if_not_exists(db) ⇒ Object



29
30
31
# File 'lib/db/load_helper.rb', line 29

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



13
14
15
16
17
18
19
# File 'lib/db/load_helper.rb', line 13

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_localObject



5
6
7
8
9
10
11
# File 'lib/db/load_helper.rb', line 5

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_serverObject



21
22
23
24
25
26
27
# File 'lib/db/load_helper.rb', line 21

def self.import_on_server()
  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