module ActiveRecord::Sharding::DatabaseTasks::TaskOrganizerForSingleClusterTask

Public Instance Methods

create_all_databases(args) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 107
def create_all_databases(args)
  exec_task_for_all_databases "create", args
end
drop_all_databases(args) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 111
def drop_all_databases(args)
  exec_task_for_all_databases "drop", args
end
load_schema_all_databases(args) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 115
def load_schema_all_databases(args)
  exec_task_for_all_databases "load_schema", args
end

Private Instance Methods

cluster_name_or_error(name, args) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 129
          def cluster_name_or_error(name, args)
            unless cluster_name = args[:cluster_name]
              $stderr.puts <<-MSG
Missing cluster_name. Find cluster_name via `rake active_record:sharding:info` then call `rake "active_record:sharding:#{name}[$cluster_name]"`.
          MSG
              exit
            end
            cluster_name
          end
cluster_or_error(cluster_name) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 139
def cluster_or_error(cluster_name)
  fetch_cluster_config cluster_name.to_sym
rescue KeyError
  $stderr.puts %(cluster name "#{cluster_name}" not found.)
  exit
end
exec_task_for_all_databases(task_name, args) click to toggle source
# File lib/active_record/sharding/database_tasks.rb, line 121
def exec_task_for_all_databases(task_name, args)
  cluster_name = cluster_name_or_error task_name, args
  cluster = cluster_or_error cluster_name
  cluster.connections.each do |connection_name|
    __send__ task_name, connection_name.to_s
  end
end