Sha256: c3598c0bd7973901f190333c338b0f1864836dc85ff873cc0b8a87eb4fa343f5

Contents?: true

Size: 1.22 KB

Versions: 38

Compression:

Stored size: 1.22 KB

Contents

namespace :load do
  task :defaults do
    set :db_roles,            -> { :db }
    set :db_backup_on_deploy, -> { false }
  end
end

namespace :db do
  
  
  desc "seed the database"
  task :seed do
    on release_roles fetch(:db_roles) do
      within current_path do
        execute :bundle, :exec, :rake, "db:seed RAILS_ENV=#{fetch(:stage)}"
      end
    end
  end
  
  desc 'Dumb database and download yaml file'
  task :yaml_dumb do
    # create local backup-dir if not existing
    run_locally do
      execute :mkdir, "-p db/backups" 
    end
    # download yaml version of current DB
    on roles :db do
      within current_path do
        execute :bundle, :exec, :rake, "db:data:dump RAILS_ENV=#{fetch(:stage)}"
        # => download! "#{current_path}/db/data.yml", "db/backups/#{ Time.now.strftime("%y-%m-%d_%H-%M") }_#{fetch(:stage)}_db_data.yml"
        execute "cd #{current_path}/db ; tar -czvf data-dumb.tar.gz data.yml"
        download! "#{current_path}/db/data-dumb.tar.gz", "db/backups/#{ Time.now.strftime("%y-%m-%d_%H-%M") }_#{fetch(:stage)}_db.tar.gz"
      end
    end
  end
  
end

namespace :deploy do
  before :starting, :backup_database do
    if fetch(:db_backup_on_deploy)
      invoke "db:yaml_dumb"
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
magic_recipes_two-0.0.91 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.90 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.89 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.88 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.87 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.86 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.85 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.84 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.83 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.82 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.81 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.80 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.79 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.78 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.77 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.76 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.75 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.74 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.73 lib/capistrano/tasks/db.rake
magic_recipes_two-0.0.72 lib/capistrano/tasks/db.rake