Browse files

Added prevention of duplicate migrations from the generator #2240 [fb…


git-svn-id: 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent df95567 commit 6d336753b9535617de105ef5494ffc3199d079b3 @dhh dhh committed Sep 24, 2005
@@ -1,5 +1,7 @@
+* Added prevention of duplicate migrations from the generator #2240 []
* 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.
@@ -2,6 +2,8 @@ class MigrationGenerator < Rails::Generator::NamedBase
def manifest
record do |m| 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")

0 comments on commit 6d33675

Please sign in to comment.