class Shred::Commands::Db

Public Instance Methods

dump() click to toggle source
# File lib/shred/commands/db.rb, line 28
def dump
  command_lines = Array(cfg('dump')).map { |v| interpolate_value(v) }
  run_shell_command(ShellCommand.new(
    command_lines: command_lines,
    success_msg: 'Database dumped',
    error_msg: 'Database could not be dumped'
  ))
end
init() click to toggle source
# File lib/shred/commands/db.rb, line 10
def init
  run_shell_command(ShellCommand.new(
    command_lines: 'bin/rake db:drop:all db:create:all db:structure:load',
    success_msg: 'Database initialized',
    error_msg: 'Database could not be initialized'
  ))
end
migrate() click to toggle source
# File lib/shred/commands/db.rb, line 19
def migrate
  run_shell_command(ShellCommand.new(
    command_lines: 'bin/rake db:migrate',
    success_msg: 'Migrations applied',
    error_msg: 'Migrations could not be applied'
  ))
end
restore(dumpfile) click to toggle source
# File lib/shred/commands/db.rb, line 38
def restore(dumpfile)
  context = {dumpfile: dumpfile}
  command_lines = Array(cfg('restore')).map { |v| interpolate_value(v, context: context) }
  run_shell_command(ShellCommand.new(
    command_lines: command_lines,
    success_msg: 'Database restored',
    error_msg: 'Database could not be restored'
  ))
end