mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Create directory before copying migrations if it does not exist
This commit is contained in:
parent
510375b501
commit
437ceab139
2 changed files with 17 additions and 0 deletions
|
@ -387,6 +387,8 @@ module ActiveRecord
|
|||
def copy(destination, sources, options = {})
|
||||
copied = []
|
||||
|
||||
FileUtils.mkdir_p(destination) unless File.exists?(destination)
|
||||
|
||||
destination_migrations = ActiveRecord::Migrator.migrations(destination)
|
||||
last = destination_migrations.last
|
||||
sources.each do |name, path|
|
||||
|
|
|
@ -2024,6 +2024,21 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
clear
|
||||
end
|
||||
|
||||
def test_copying_migrations_to_non_existing_directory
|
||||
@migrations_path = MIGRATIONS_ROOT + "/non_existing"
|
||||
@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.rb")
|
||||
assert File.exists?(@migrations_path + "/20100726101011_people_have_descriptions.rb")
|
||||
assert_equal 2, copied.length
|
||||
end
|
||||
ensure
|
||||
clear
|
||||
Dir.delete(@migrations_path)
|
||||
end
|
||||
|
||||
def test_copying_migrations_to_empty_directory
|
||||
@migrations_path = MIGRATIONS_ROOT + "/empty"
|
||||
@existing_migrations = []
|
||||
|
|
Loading…
Reference in a new issue