Module: Octopus::Migration::ClassMethods

Defined in:
lib/octopus/migration.rb

Instance Method Summary collapse

Instance Method Details

#shardsObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/octopus/migration.rb', line 44

def shards
  shards = Set.new

  if (groups = (current_group_specified ? current_group : Octopus.config[:default_migration_group]))
    Array.wrap(groups).each do |group|
      group_shards = connection.shards_for_group(group)
      shards.merge(group_shards) if group_shards
    end
  elsif (shard = current_shard)
    shards.merge(Array.wrap(shard))
  end

  shards.to_a.presence || [Octopus.master_shard]
end

#using(*args) ⇒ Object


29
30
31
32
33
34
# File 'lib/octopus/migration.rb', line 29

def using(*args)
  return self unless connection.is_a?(Octopus::Proxy)

  self.current_shard = args
  self
end

#using_group(*groups) ⇒ Object


36
37
38
39
40
41
42
# File 'lib/octopus/migration.rb', line 36

def using_group(*groups)
  return self unless connection.is_a?(Octopus::Proxy)

  self.current_group = groups
  self.current_group_specified = true
  self
end