Module: ActiveRecord::Turntable::Migration::ShardDefinition

Defined in:
lib/active_record/turntable/migration.rb

Instance Method Summary collapse

Instance Method Details

#clusters(*cluster_names) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_record/turntable/migration.rb', line 14

def clusters(*cluster_names)
  config = ActiveRecord::Base.turntable_config
  (self.target_shards ||= []) <<
    if cluster_names.first == :all
      config['clusters'].map do |name, cluster_conf|
        cluster_conf["shards"].map {|shard| shard["connection"]}
      end
    else
      cluster_names.map do |cluster_name|
        config['clusters'][cluster_name]["shards"].map do |shard|
          shard["connection"]
        end
      end
    end
end

#shards(*connection_names) ⇒ Object



30
31
32
# File 'lib/active_record/turntable/migration.rb', line 30

def shards(*connection_names)
  (self.target_shards ||= []) << connection_names
end