Module: ActiveRecordShards::ActualMigrationExtension

Defined in:
lib/active_record_shards/migration.rb

Instance Method Summary collapse

Instance Method Details

#migrate_with_forced_shard(direction) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/active_record_shards/migration.rb', line 93

def migrate_with_forced_shard(direction)
  if migration_shard.blank?
    raise "#{name}: Can't run migrations without a shard spec: this may be :all, :none,
             or a specific shard (for data-fixups).  please call shard(arg) in your migration."
  end

  shard = ActiveRecord::Base.current_shard_selection.shard

  if shard.nil?
    return if migration_shard != :none
  else
    return if migration_shard == :none
    return if migration_shard != :all && migration_shard.to_s != shard.to_s
  end

  migrate_without_forced_shard(direction)
end

#migration_shardObject



111
112
113
# File 'lib/active_record_shards/migration.rb', line 111

def migration_shard
  self.class.migration_shard
end