From 652db2fc3e1d62737e4bedb3b7cee313d7400c0a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 9 Dec 2011 00:50:39 +0100 Subject: Fix copying migrations from engines There was a bug in ActiveRecord::Migration.copy method, which prevented adding special comment about the origin of migration. Because of that, the check if migration is identical or if it's not and should be skipped was always saying that migration is skipped, which was causing additional useless warnings about skipped migrations. --- activerecord/lib/active_record/migration.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index e53d5e7167..1d450da006 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -461,11 +461,11 @@ module ActiveRecord source_migrations = ActiveRecord::Migrator.migrations(path) source_migrations.each do |migration| - source = File.read(migration.filename) + source = File.read(migration.filename).chomp source = "# This migration comes from #{name} (originally #{migration.version})\n#{source}" if duplicate = destination_migrations.detect { |m| m.name == migration.name } - options[:on_skip].call(name, migration) if File.read(duplicate.filename) != source && options[:on_skip] + options[:on_skip].call(name, migration) if File.read(duplicate.filename).chomp != source && options[:on_skip] next end @@ -474,7 +474,7 @@ module ActiveRecord old_path, migration.filename = migration.filename, new_path last = migration - FileUtils.cp(old_path, migration.filename) + File.open(migration.filename, "w") { |f| f.write source } copied << migration options[:on_copy].call(name, migration, old_path) if options[:on_copy] destination_migrations << migration -- cgit v1.2.3