Sha256: 01eea121bc66d612a1ace97a90e312fde6f1023c3c33ccebdff7de7c24fa4092

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require_relative('../../db/helper.rb')
require_relative('../../db/dump_helper.rb')
require_relative('../../db/load_helper.rb')

namespace :db do
  desc "export a local, remote or remote container mysql db"
  task :export do
    on roles(:db, :container_host) do |host|
      if fetch(:db_is_container)
        DumpHelper::dump_on_container_and_download container_by_name(fetch(:db_container_name))
      elsif Helper::local_stage?
        DumpHelper::dump_on_local
      else
        DumpHelper::dump_on_server_and_download
      end

      Helper::duplicate_local_dump_to_staged_dump
    end
  end

  desc "import a local, remote or remote container mysql db"
  task :import do
    on roles(:db, :container_host) do
      if fetch(:db_is_container)
        LoadHelper::import_on_container container_by_name(fetch(:db_container_name))
      elsif Helper::local_stage?
        LoadHelper::import_on_local
      else
        LoadHelper::import_on_server
      end
    end
  end
end

namespace :load do
  task :defaults do
    set :db_user, 'root'
    set :db_pass, ''
    set :db_name, ''
    set :db_remote_dump, '/tmp/dump.sql'
    set :db_local_dump, 'config/db/dump.sql'
    set :db_is_container, false
    set :db_container_name, 'db'
    set :local_stage_name, :local
    set :filter_on_import, lambda{ |sql_dump| return sql_dump }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-container-db-0.0.4 lib/capistrano/tasks/db.rb
capistrano-container-db-0.0.3 lib/capistrano/tasks/db.rb