mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
parent
df95567598
commit
6d336753b9
2 changed files with 4 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*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).
|
* 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.
|
* 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
|
def manifest
|
||||||
record do |m|
|
record do |m|
|
||||||
m.directory File.join('db/migrate')
|
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
|
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")
|
m.template 'migration.rb', File.join('db/migrate', "#{next_migration_number}_#{file_name}.rb")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue