Added prevention of duplicate migrations from the generator #2240 [fbeausoleil@ftml.net]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2320 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-09-24 08:42:38 +00:00
parent df95567598
commit 6d336753b9
2 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Added prevention of duplicate migrations from the generator #2240 [fbeausoleil@ftml.net]
* Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file).
* Reformed all the config/environments/* files to conform to the new Rails::Configuration approach. Fully backwards compatible.

View File

@ -2,6 +2,8 @@ class MigrationGenerator < Rails::Generator::NamedBase
def manifest
record do |m|
m.directory File.join('db/migrate')
existing_migrations = Dir.glob("db/migrate/[0-9]*_#{file_name}.rb")
raise "Another migration already exists with the same name" unless existing_migrations.empty?
next_migration_number = Dir.glob("db/migrate/[0-9]*.*").size + 1
m.template 'migration.rb', File.join('db/migrate', "#{next_migration_number}_#{file_name}.rb")
end