Sha256: dea6a25e545ce8779f2924ee0c86b63b357f7df9f514cb13ade4012f799ca060

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

if File.exist? Rails.root.join('config/database.yml')
  namespace :mysql do
    config = YAML.load(File.read(Rails.root.join('config/database.yml')))[Rails.env.to_s]
    if config['adapter'] == 'mysql2'
      db = config['database']
      host = config['host']
      FileUtils.mkdir_p Rails.root.join('mysql')

      backup = "mysqldump -h #{host} #{db} > #{Rails.root}/mysql/dump.sql"
      desc backup
      task :dump do
        zfben_rails_rake_system backup
      end

      restore = "mysql -h #{host} #{db} < #{Rails.root}/mysql/dump.sql"
      desc restore
      task :restore => 'db:create' do
        zfben_rails_rake_system restore
      end

      backup_all = "mysqldump -h #{host} --all-databases > #{Rails.root}/mysql/dump_all.sql"
      desc backup_all
      task :dump_all do
        zfben_rails_rake_system backup_all
      end

      restore_all = "mysql -h #{host} < #{Rails.root}/mysql/dump_all.sql"
      desc restore_all
      task :restore_all => 'db:create' do
        zfben_rails_rake_system restore_all
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
h2ocube_rails_tasks-0.0.14 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.13 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.12 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.11 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.10 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.9 lib/h2ocube_rails_tasks/tasks/mysql.rb
h2ocube_rails_tasks-0.0.8 lib/h2ocube_rails_tasks/tasks/mysql.rb