提交 e063879d 编写于 作者: P Piotr Sarnacki

Fix copying migrations to empty directory

上级 c7664d11
......@@ -395,7 +395,7 @@ def copy(destination, sources)
source_migrations.each do |migration|
next if destination_migrations.any? { |m| m.name == migration.name && m.scope == scope.to_s }
migration.version = next_migration_number(last.version + 1).to_i
migration.version = next_migration_number(last ? last.version + 1 : 0).to_i
last = migration
new_path = File.join(destination, "#{migration.version}_#{migration.name.underscore}.#{scope}.rb")
......
......@@ -1985,6 +1985,20 @@ def test_copying_migrations_with_timestamps_to_destination_with_timestamps_in_fu
ensure
clear
end
def test_copying_migrations_to_empty_directory
@migrations_path = MIGRATIONS_ROOT + "/empty"
@existing_migrations = []
Time.travel_to(created_at = Time.utc(2010, 7, 26, 10, 10, 10)) do
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
assert File.exists?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb")
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb")
assert_equal 2, copied.length
end
ensure
clear
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册