mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:01 -05:00
Fix copying migrations to empty directory
This commit is contained in:
@@ -395,7 +395,7 @@ module ActiveRecord
|
||||
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 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||
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
|
||||
|
||||
|
||||
0
activerecord/test/migrations/empty/.gitkeep
Normal file
0
activerecord/test/migrations/empty/.gitkeep
Normal file
Reference in New Issue
Block a user