Sha256: 47bc38ecafc01fe0c50f7002cc1c972fcdcf64ec77a4fd53931d0ca643580a6b

Contents?: true

Size: 862 Bytes

Versions: 11

Compression:

Stored size: 862 Bytes

Contents

namespace :db do

  desc 'Dump the database to the specified file'
  task :dump, :file do |t, args|
    raise "file argument required" unless args[:file]
    db_config = WCC::RakeHelpers.db_config
    command = [
      "mysqldump",
      "--user=#{db_config['username']}",
      "--password=#{db_config['password']}",
      "#{db_config['database']}",
      "> #{args[:file]}"
    ]
    WCC::RakeHelpers.db_cmd_with_password(command)
  end

  desc 'Restore the datbase from the specified file'
  task :restore, :file do |t, args|
    raise "file argument required" unless File.exists?(args[:file])
    db_config = WCC::RakeHelpers.db_config
    command = [
      "cat #{args[:file]} | mysql --user=#{db_config['username']} --password=#{db_config['password']}",
      db_config['database'],
    ].join(" ")
    `#{command}`
  end

end if WCC::RakeHelpers.mysql?

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wcc-base-0.3.3 lib/tasks/db/mysql.rake
wcc-base-0.3.2 lib/tasks/db/mysql.rake
wcc-base-0.3.1 lib/tasks/db/mysql.rake
wcc-base-0.3.0 lib/tasks/db/mysql.rake
wcc-base-0.2.2 lib/tasks/db/mysql.rake
wcc-base-0.2.1 lib/tasks/db/mysql.rake
wcc-base-0.2.0 lib/tasks/db/mysql.rake
wcc-base-0.1.3 lib/tasks/db/mysql.rake
wcc-base-0.1.2 lib/tasks/db/mysql.rake
wcc-base-0.1.1 lib/tasks/db/mysql.rake
wcc-base-0.1.0 lib/tasks/db/mysql.rake