Module: Dumpman::Database

Defined in:
lib/dumpman/database.rb

Class Method Summary collapse

Class Method Details

.createObject



18
19
20
21
# File 'lib/dumpman/database.rb', line 18

def create
  cmd = strategy.create_cmd
  Dumpman::Executor.system(cmd)
end

.dropObject



13
14
15
16
# File 'lib/dumpman/database.rb', line 13

def drop
  cmd = strategy.drop_cmd
  Dumpman::Executor.system(cmd)
end

.dumpObject



3
4
5
6
# File 'lib/dumpman/database.rb', line 3

def dump
  cmd = strategy.dump_cmd
  Dumpman::Executor.system(cmd)
end

.restoreObject



8
9
10
11
# File 'lib/dumpman/database.rb', line 8

def restore
  cmd = strategy.restore_cmd
  Dumpman::Executor.system(cmd)
end

.strategyObject



23
24
25
26
27
28
29
30
# File 'lib/dumpman/database.rb', line 23

def strategy
  case ActiveRecord::Base.connection_config.fetch(:adapter)
  when 'postgresql' then Dumpman::Adapters::Pg
  when 'mysql', 'mysql2' then Dumpman::Adapters::Mysql
  else
    raise('unknown adapter in "config/database.yml"')
  end
end