Sha256: 785a7de20890d4c78cdfc759f44ce069aa1683ecc37ff225da1e6e2999b269b1

Contents?: true

Size: 1.85 KB

Versions: 32

Compression:

Stored size: 1.85 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'
option :select_server, :default => false, :type => :boolean, :aliases => '-s'

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

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

      loader = DumpLoader.new(options.load)

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

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

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

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

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

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

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

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
geordi-2.12.3 lib/geordi/commands/dump.rb
geordi-2.12.2 lib/geordi/commands/dump.rb
geordi-2.12.1 lib/geordi/commands/dump.rb
geordi-2.12.0 lib/geordi/commands/dump.rb
geordi-2.11.0 lib/geordi/commands/dump.rb
geordi-2.10.1 lib/geordi/commands/dump.rb
geordi-2.10.0 lib/geordi/commands/dump.rb
geordi-2.9.0 lib/geordi/commands/dump.rb
geordi-2.8.0 lib/geordi/commands/dump.rb
geordi-2.7.0 lib/geordi/commands/dump.rb
geordi-2.6.0 lib/geordi/commands/dump.rb
geordi-2.5.0 lib/geordi/commands/dump.rb
geordi-2.4.0 lib/geordi/commands/dump.rb
geordi-2.3.0 lib/geordi/commands/dump.rb
geordi-2.2.0 lib/geordi/commands/dump.rb
geordi-2.1.0 lib/geordi/commands/dump.rb
geordi-2.0.0 lib/geordi/commands/dump.rb
geordi-1.10.0 lib/geordi/commands/dump.rb
geordi-1.9.1 lib/geordi/commands/dump.rb
geordi-1.9.0 lib/geordi/commands/dump.rb