module Dumpman::Database

Public Class Methods

create() click to toggle source
# File lib/dumpman/database.rb, line 18
def create
  cmd = strategy.create_cmd
  Dumpman::Executor.system(cmd)
end
drop() click to toggle source
# File lib/dumpman/database.rb, line 13
def drop
  cmd = strategy.drop_cmd
  Dumpman::Executor.system(cmd)
end
dump() click to toggle source
# File lib/dumpman/database.rb, line 3
def dump
  cmd = strategy.dump_cmd
  Dumpman::Executor.system(cmd)
end
restore() click to toggle source
# File lib/dumpman/database.rb, line 8
def restore
  cmd = strategy.restore_cmd
  Dumpman::Executor.system(cmd)
end
strategy() click to toggle source
# 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

Private Instance Methods

create() click to toggle source
# File lib/dumpman/database.rb, line 18
def create
  cmd = strategy.create_cmd
  Dumpman::Executor.system(cmd)
end
drop() click to toggle source
# File lib/dumpman/database.rb, line 13
def drop
  cmd = strategy.drop_cmd
  Dumpman::Executor.system(cmd)
end
dump() click to toggle source
# File lib/dumpman/database.rb, line 3
def dump
  cmd = strategy.dump_cmd
  Dumpman::Executor.system(cmd)
end
restore() click to toggle source
# File lib/dumpman/database.rb, line 8
def restore
  cmd = strategy.restore_cmd
  Dumpman::Executor.system(cmd)
end
strategy() click to toggle source
# 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