diff options
author | David Trasbo <me@dtrasbo.com> | 2010-09-02 16:25:36 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-18 21:22:29 +0200 |
commit | e8082246529737b6cf0d5cc3c948e54896aa1329 (patch) | |
tree | f721a0ae3648f9733f433bc403a7336ddf42440d /railties/lib/rails | |
parent | 20685d07ab5853457e1d11467f22ed42568e20f4 (diff) | |
download | rails-e8082246529737b6cf0d5cc3c948e54896aa1329.tar.gz rails-e8082246529737b6cf0d5cc3c948e54896aa1329.tar.bz2 rails-e8082246529737b6cf0d5cc3c948e54896aa1329.zip |
Remove existing migration when using 'rails generate model' with --force [#5526 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/generators/migration.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 9244307261..8d98909055 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -53,7 +53,11 @@ module Rails destination = self.class.migration_exists?(migration_dir, @migration_file_name) if behavior == :invoke - raise Error, "Another migration is already named #{@migration_file_name}: #{destination}" if destination + if destination && options.force? + remove_file(destination) + elsif destination + raise Error, "Another migration is already named #{@migration_file_name}: #{destination}" + end destination = File.join(migration_dir, "#{@migration_number}_#{@migration_file_name}.rb") end |