aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-13 11:44:56 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-13 14:33:59 -0800
commit5e616379ccabce7196820ff517d34ed56ef2a160 (patch)
treec0e0c4135f8e41caaa45ed8d451eadc01bb7ab7a /activerecord/lib/active_record/migration.rb
parent280e4cba13e3aa332496280d3d74b00fdbaeeced (diff)
downloadrails-5e616379ccabce7196820ff517d34ed56ef2a160.tar.gz
rails-5e616379ccabce7196820ff517d34ed56ef2a160.tar.bz2
rails-5e616379ccabce7196820ff517d34ed56ef2a160.zip
deprecate the block argument to Migrator#migrate
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r--activerecord/lib/active_record/migration.rb27
1 files changed, 19 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index e8f4eff0d9..40274b3c2b 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -566,12 +566,18 @@ module ActiveRecord
move(:up, migrations_paths, steps)
end
- def up(migrations_paths, target_version = nil, &block)
- self.new(:up, migrations(migrations_paths), target_version).migrate(&block)
+ def up(migrations_paths, target_version = nil)
+ migrations = migrations(migrations_paths)
+ migrations.select! { |m| yield m } if block_given?
+
+ self.new(:up, migrations, target_version).migrate
end
def down(migrations_paths, target_version = nil, &block)
- self.new(:down, migrations(migrations_paths), target_version).migrate(&block)
+ migrations = migrations(migrations_paths)
+ migrations.select! { |m| yield m } if block_given?
+
+ self.new(:down, migrations, target_version).migrate
end
def run(direction, migrations_paths, target_version)
@@ -681,16 +687,21 @@ module ActiveRecord
end
end
- def migrate(&block)
+ def migrate
if !target && @target_version && @target_version > 0
raise UnknownMigrationVersionError.new(@target_version)
end
- runnable.each do |migration|
- if block && !block.call(migration)
- next
- end
+ running = runnable
+
+ if block_given?
+ ActiveSupport::Deprecation.warn(<<-eomsg)
+block argument to migrate is deprecated, please filter migrations before constructing the migrator
+ eomsg
+ running.select! { |m| yield m }
+ end
+ running.each do |migration|
Base.logger.info "Migrating to #{migration.name} (#{migration.version})" if Base.logger
begin