Sha256: 0df3c77e368122745cbbfbff6c1a147601101acdb998eaf65307328ef84697b5

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

desc 'dump [TARGET]', 'Handle dumps (see `geordi help dump` for details)'
long_desc <<-DESC
When called without arguments, dumps the development database with `dumple`.

    geordi dump

When called with the `--load` option, sources the specified dump into the
development database.

    geordi dump -l tmp/staging.dump

When called with a capistrano deploy target (e.g. `staging`), remotely dumps
the specified target's database and downloads it to `tmp/`.

    geordi dump staging

When called with a capistrano deploy target and the `--load` option, sources the
dump into the development database after downloading it.

    geordi dump staging -l
DESC

option :load, aliases: ['-l'], type: :string, desc: 'Load a dump'

def dump(target = nil, *_args)
  require 'geordi/dump_loader'
  require 'geordi/remote'

  if target.nil?
    if options.load
      # validate load option
      Interaction.fail 'Missing a dump file.' if options.load == 'load'
      File.exist?(options.load) || raise('Could not find the given dump file: ' + options.load)

      loader = DumpLoader.new(options.load)

      Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
      loader.load

      Interaction.success "Your #{loader.config['database']} database has now the data of #{options.load}."

    else
      Interaction.announce 'Dumping the development database'
      Util.system! 'dumple development'
      Interaction.success 'Successfully dumped the development database.'
    end

  else
    Interaction.announce 'Dumping the database of ' + target
    dump_path = Geordi::Remote.new(target).dump(options)

    if options.load
      loader = DumpLoader.new(dump_path)

      Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
      loader.load

      Interaction.success "Your #{loader.config['database']} database has now the data of #{target}."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geordi-3.2.0 lib/geordi/commands/dump.rb